El Noobie [https://community.jboss.org/people/elnoobie] created the discussion

"Getting Up & Running with MySQL, DataNucleus & JDO"

To view the discussion, visit: https://community.jboss.org/message/831210#831210

--------------------------------------------------------------
*Warning*:  I am a complete newbie with JBoss AS7.

*The Goal & Tools*
My primary goal is to get a complete service up and running locally (at first). 
 Later I will worry about moving things to OpenShift and playing around with 
that.  The key tool for all of this is just going to be use of Maven 3.x in 
order to get things built & deployed locally.  Therefore I'd like to stick with 
the standard Maven conventions for everything.*
*

*Where I Am Sucessful*

1. Able to get the core of everything working with JSF, some REST & SOAP WS, 
XML/JSON setup, etc.
2. Able to get a bunch of OSGi stuff running
3. Figured out a bunch of logging issues so I can get Logback with SLF4J running
4. No issues deploying/undeploying anything via Maven
5. Using Liquibase for the basic database setup which was really easy
6. All is good with getting MySQL up, recognized and tested via the web 
console1. Added MySQL as a module
2. Added DataNucleus as a module
3. Defiend 2 data sources:  1 with JPA, 1 without


I was able to follow the basics with the help of a couple web articles:

*  https://community.jboss.org/docs/DOC-17094?_sscc=t 
https://community.jboss.org/wiki/GettingStartedWithJDOOnJbossAS7InSevenSteps?_sscc=t
*  
http://hwellmann.blogspot.com/2011/10/jboss-as-7-catching-up-with-java-ee-6.html
 
http://hwellmann.blogspot.com/2011/10/jboss-as-7-catching-up-with-java-ee-6.html

*Where I Am Stuck*
So now I am starting to get to the recognition of the data source(s) within 
JBoss and hoping to move quickly onto the DataNucleus and JDO end of things.  
However, I cannot get the data source reference via a context lookup without 
getting a "+Name Not Found+" exception.  I really want to get this 
piece-by-piece to understand the inner workings and therefore I don't want to 
skip this step before moving on to the setup of +persistence.xml+ and whatnot.

My data sources are setup like this in +standalone.xml+:


<datasource jta="false" jndi-name="java:/datasources/testMeDS" 
pool-name="testMeDS-pool" enabled="true" use-java-context="true" use-ccm="true">
...

</datasource>



<datasource jta="true" jndi-name="java:/datasources/testMeDS-JTA" 
pool-name="testMeDS-JTA-pool" enabled="true" use-java-context="true" 
use-ccm="true">
...

</datasource>



In my simple, little JAX-RS setup I created a +DataSourceService+ class that 
looks like this:


@Path ("/dstest")
public class DataSourceService {
 
  @Context
  HttpServletRequest request;
 
  @GET
  @Produces({MediaType.APPLICATION_XML})
  public DSTestDocument getDataSourceTestResults() {
    try {
      // Obtain our environment naming context
      InitialContext initCtx = new InitialContext();
      javax.naming.Context envCtx = (javax.naming.Context) 
initCtx.lookup("java:comp/env");
 
 
      // Look up our data source
      Object lol = envCtx.lookup("java:/datasources/testMeDS");
    } catch (Exception e) {
      e.printStackTrace(System.err);
    }
 
    // build the document
    // ...
    // do some logging
    // ...
    return theResopnseDocumentObject;
  }
}


I get the following exception:

> [stderr] (http--0.0.0.0-8080-1) javax.naming.NameNotFoundException: 
> jboss/datasources/testMeDS -- service 
> jboss.naming.context.java.module.ElTesting."webservices-1.0-SNAPSHOT".jboss.datasources.testMeDS
>       at 
> org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
>       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
>       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)
> 

Can someone help me out so I can move on to the next steps?

I know that I won't follow  https://community.jboss.org/docs/DOC-17094?_sscc=t 
steps 5 and 6 from the one article listed above exactly - and I will tackle 
that mountain when I get to it. I know I'll need to setup the +persistence.xml+ 
and other things but I am not even going to bother to try until I get this part 
resolved.  I want to make sure I can connect to the data source and do some 
things manually before that.  That gives me an opportunity to play with more 
CDI and various other things utilizing JBoss to get a better understanding of 
the options opened and internal workings.

Thanks in advance!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/831210#831210]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to