4 Replies Latest reply on Mar 1, 2002 8:12 AM by per_nyfelt

    Defining / accessing a data source in JBoss3.0 beta

    per_nyfelt

      I'm using JBoss 3.0 beta trying to connect to a mySQL db.

      I follwed the example mySQL file in CVS to set up a data source and it looks like it works since i get the following output on the server console:

      17:42:38,972 INFO [resnet] PrincipalMapping properties set to: {UserName=}
      17:42:38,982 INFO [resnet] Bound connection factory for resource adapter 'jboss.jca:service=RARDeployment,name=Minerva JDBC LocalTransaction Resource Adapter' to JNDI name 'java:/resnet'
      17:42:39,012 INFO [resnet] Started

      I then try to reference that datasource in jbosscmp-jdbc as resnet but on deploy i get an error saying the server cannot find it:

      18:03:34,197 ERROR [EntityContainer] Exception in service lifecyle operation: create
      org.jboss.deployment.DeploymentException: Error: can't find data source: resnet

      Using the jmx agent view i find the DS under jboss.management.single listed as J2EEDomain=Manager,name=resnet,J2EEServer=Single,type=JDBCDataSource,JDBC=JDBC

      But I'm unable to find the object in JNDI using "java:/resnet" as the lookup string.

      Does anyone have any suggestions of what could be wrong here? Is it the datasource set-up that has issues or am i looking for the wrong name?

      Best regards,
      Per

        • 1. Re: Defining / accessing a data source in JBoss3.0 beta
          davidjencks

          I think the log you show indicates that the datasource is successfully deployed and bound in jndi. Check in jndi view to see what it is bound under. Check the connectionfactoryloader mbean (not the jsr-77 one) to make sure all the properties are as you expect and that it is started.

          I think there is a naming problem, which I usually get confused with. Have you tried java:/resnet?

          • 2. Re: Defining / accessing a data source in JBoss3.0 beta
            per_nyfelt

            Thanks for the quick reply. Using java:/resnet in the jbosscmp-jdbc works for the entity beans :).

            I still cannot find the datasource with a straight JNDI though, if I do:

            Hashtable props = new Hashtable();
            props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
            props.put(Context.PROVIDER_URL, "localhost:1099");
            Context ctx = new InitialContext(props);
            Object obj = ctx.lookup("resnet");

            I get javax.naming.NameNotFoundException: resnet not bound

            I've also tried java:/resnet, java:comp/env/resnet and any other combination i could think of.

            In the jboss.jca:service=ConnectionFactoryLoader,name=resnet the JndiName has the value resnet so I do not understand why i cant find such an object in JNDI bound as resnet. I must be missing something.

            Any ideas would be much appreciated.

            • 3. Re: Defining / accessing a data source in JBoss3.0 beta
              davidjencks

              Since you are trying to set props for your initial context, maybe you are trying to get the datasource from another vm. YOU CANT, STOP TRYING. The java: namespace is accessible only from in-vm. I assume you know about jndiview accessible on port 8082?

              • 4. Re: Defining / accessing a data source in JBoss3.0 beta
                per_nyfelt

                Oh, I didn't know that. This explains why my Junit tests are failing even though it actually works. I'll switch to Cactus for those tests instead. Thanks for the information :)

                Best regards,
                Per