8 Replies Latest reply on Jul 19, 2002 5:07 AM by tdang

    JNDI-Name of DataSource

    tdang

      Hi!

      I am using JBoss 3.0.

      <?xml version="1.0" encoding="UTF-8"?>

      <!-- ==================================================================== -->
      <!-- ConnectionManager setup for default IBM DB2 -->
      <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
      <!-- ==================================================================== -->






      <!-- Include a login module configuration named DB2DbRealm.
      Update your login-conf.xml, here is an example for a
      ConfiguredIdentityLoginModule:

      <application-policy name = "DB2DbRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal">yourprincipal</module-option>
      <module-option name = "userName">yourusername</module-option>
      <module-option name = "password">yourpassword</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DB2DS</module-option>
      </login-module>

      </application-policy>

      NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
      module-option name = "managedConnectionFactoryName"
      must match the object name of the ConnectionManager you are configuring here.
      -->
      <!--uncomment out this line if you are using the DB2DbRealm above
      DB2DbRealm
      -->

      <depends optional-attribute-name="ManagedConnectionFactoryName">
      <!--embedded mbean-->


      Sales


      <config-property name="ConnectionURL" type="java.lang.String">jdbc:db2:salesDB</config-property>
      <config-property name="DriverClass" type="java.lang.String">COM.ibm.db2.jdbc.app.DB2Driver</config-property>
      <!--set these only if you want only default logins, not through JAAS -->
      <config-property name="UserName" type="java.lang.String"></config-property>
      <config-property name="Password" type="java.lang.String"></config-property>



      <!--Below here are advanced properties -->
      <!--hack-->
      <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper


      <depends optional-attribute-name="ManagedConnectionPool">

      <!--embedded mbean-->

      0
      50
      5000
      15
      <!--
      criteria indicates if Subject (from security domain) or app supplied
      parameters (such as from getConnection(user, pw)) are used to distinguish
      connections in the pool. Choices are
      ByContainerAndApplication (use both),
      ByContainer (use Subject),
      ByApplication (use app supplied params only),
      ByNothing (all connections are equivalent, usually if adapter supports
      reauthentication)-->
      ByContainer


      <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager

      <!-- <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager -->

      java:/TransactionManager
      <!--make the rar deploy! hack till better deployment-->
      jboss.jca:service=RARDeployer




      -----------------------------------------------------
      I have configured my datasource in the above kursvs-service.xml file. I copied it to %JBOSS_INST%\server\default\deploy.

      In the server.log file there are the following lines:

      2002-07-16 17:31:13,484 DEBUG [org.jboss.deployment.MainDeployer] create step for deployment file:/C:/Programme/jboss 3.0/server/default/deploy/kursvs-service.xml
      2002-07-16 17:31:13,484 DEBUG [org.jboss.deployment.SARDeployer] Deploying SAR, create step: url file:/C:/Programme/jboss 3.0/server/default/deploy/kursvs-service.xml
      2002-07-16 17:31:13,484 DEBUG [org.jboss.system.ServiceCreator] About to create bean: jboss.jca:service=LocalTxCM,name=DB2DS
      2002-07-16 17:31:13,484 DEBUG [org.jboss.system.ServiceCreator] code: org.jboss.resource.connectionmanager.LocalTxConnectionManager

      ...
      2002-07-16 17:31:13,531 DEBUG [org.jboss.system.ServiceConfigurator] JndiName set to Sales in jboss.jca:service=LocalTxDS,name=DB2DS

      ...
      2002-07-16 17:31:13,609 WARN [org.jboss.system.ServiceController] jboss.jca:service=LocalTxDS,name=DB2DS does not implement any Service methods

      ...
      2002-07-16 17:31:13,609 DEBUG [org.jboss.deployment.SARDeployer] Deploying SAR, start step: url file:/C:/Programme/jboss 3.0/server/default/deploy/kursvs-service.xml
      2002-07-16 17:31:13,609 DEBUG [org.jboss.system.ServiceController] waiting in start jboss.jca:service=LocalTxCM,name=DB2DS on jboss.jca:service=LocalTxDS,name=DB2DS
      2002-07-16 17:31:13,609 DEBUG [org.jboss.system.ServiceController] waiting in start jboss.jca:service=LocalTxDS,name=DB2DS on jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper
      2002-07-16 17:31:13,609 INFO [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Starting
      2002-07-16 17:31:13,625 INFO [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Started
      2002-07-16 17:31:13,625 DEBUG [org.jboss.system.ServiceController] waiting in start jboss.jca:service=LocalTxCM,name=DB2DS on jboss.jca:service=LocalTxDS,name=DB2DS
      2002-07-16 17:31:13,625 DEBUG [org.jboss.deployment.MainDeployer] Final (start) deployment step successfully completed on package: kursvs-service.xml
      2002-07-16 17:31:13,625 INFO [org.jboss.deployment.MainDeployer] Successfully completed deployment of package: file:/C:/Programme/jboss 3.0/server/default/deploy/kursvs-service.xml


      As you have seen, JBoss deployed the service correctly .

      But when I look up in the jboss:service=JNDIView\java: Namespace, I did not find the jndi-name of the datasource. So when my client runs like this:

      ...
      public class Client {
      public static void main(String[] args) {
      Properties p = new Properties();

      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

      InitialContext ctx = new InitialContext(p);
      DataSource ds = (DataSource) ctx.lookup("java:/Sales");
      Connection con = ds.getConnection();


      }
      }

      I got the exception the datasource was not found.

      What is wrong with my service.xml file? What must I do?

      Regards

        • 1. Re: JNDI-Name of DataSource
          pmgremo

          I have the exact same problem.

          My theory is that you can't access java: outside of jboss (ie: standalone client), but it would be nice to know for sure.

          • 2. Re: JNDI-Name of DataSource
            jlmartinez

            I´ve lost a lot of time whit this problem and nothing.
            But I am trying to access de datasource inside JBoss, so ... the problem isn't the stand alone client.

            If you find the solution, please help me

            Thank you.

            • 3. Re: JNDI-Name of DataSource
              gneeri

              Hi-

              As some of you know, (sorry for not getting back to you sooner Jose), I posted the same problem last week: (http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ only solution that I found comes straight out of another forum post:

              http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ it basically states that the "java:/" namespace is not available outside of the container. Working off of that, I found that I was able to implement the same code as I used in my earlier posting in both servlet and SessionBean contexts. In both cases, JNDI resolved properly and I was able to access my data without any problems.

              I hope this helps.

              --jonathan

              P.S. Thanks to Chris for the original posting.

              • 4. Re: JNDI-Name of DataSource
                gneeri

                Sorry for not reading the thread more closely; nevertheless, the "container" issue was certainly my problem and the internal solution did work, though aparently, there may be other issues afoot.

                • 5. Re: JNDI-Name of DataSource
                  tdang

                  Hi!

                  I do not only have problem with the client. Another problem is: When I deployed my bean, I got a problem that JBoss cannot find the datasource so that JBoss cannot deploy the bean.

                  If it is correct as you said that the the "java:/" namespace is not available outside of the container, I won't do this any more, but what is about the problem during deployment Jboss did not find the datasource. How can I solve the problem?

                  Please tell me if you need posting the project and his configuration files to research it more, I would like do this.

                  Thanks

                  • 6. Re: JNDI-Name of DataSource
                    gneeri

                    When my instance of JBoss starts up, I get an INFO message about the binding of the datasource name:

                    16:19:27,709 INFO [PostgresDS] Bound connection factory for resource adapter 'JBoss LocalTransaction JDBC Wrapper' to JNDI name 'java:/PostgresDS'

                    not a DEBUG message, as you seem to get. I really don't know, but this may be related to the problem. Per the posting that I referred to yesterday (about the "java:/" namespace), I would try going to

                    http://localhost:8082/InvokeAction//jboss%3Aservice%3DJNDIView/action=list?action=list&boolean%2Bboolean=true

                    to insure that your datasource shows up under the "java:" Namespace.

                    • 7. Re: JNDI-Name of DataSource
                      tdang

                      I looked up the "java:" Namespace, but it is not there. That is my problem. I do not know why.

                      • 8. Re: JNDI-Name of DataSource
                        tdang

                        I got it. The problem was I got the wrong number version of JBoss. I could successfully deploy my datasouce, now.