1 Reply Latest reply on Dec 18, 2008 7:52 AM by nouredine13

    lookup remote DataSource fail with JBoss 5 GA

    nouredine13

      Hello,

      i'm working on j2ee application running on JBoss 5 GA and want
      to lookup a remote datasource I configured. The datasource is mapped to an
      Oracle 9.0.2 DB.

      I configured the datasource within
      $JBOSS/server/default/deploy/oracle-ds.xml
      -----------------------------------------------------------

      <local-tx-datasource>
      <jndi-name>jdbc/cless-ds</jndi-name>
      <connection-url>jdbc:oracle:thin:@londres:1521:MMSERVER</connection-url>
      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      <user-name>xyz</user-name>
      xyz
      ...
      -----------------------------------------------------------------

      when I try to lookup the datasource with a simple client, with something like this :
      ...
      Context ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup("java:jdbc/cless-ds");
      ....
      ----------------------------------------------------------------

      i have the following exception :

      javax.naming.NameNotFoundException: jdbc not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:713)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
      ....

      I Would be very glad for any hint.

      Thank's a lot.

        • 1. Re: lookup remote DataSource fail with JBoss 5 GA
          nouredine13

          i have found the solution:

          The one change that is necessary for the client to be able to lookup the DataSource from JNDI is to specify use-java-context=false as shown here:


          <local-tx-datasource>
          <jndi-name>GenericDS</jndi-name>
          <use-java-context>false</use-java-context>
          <connection-url>...</connection-url>
          ...


          This results in the DataSource being bound under the JNDI name "GenericDS" instead of the default of "java:/GenericDS" which restricts the lookup to the same VM as the jboss server.

          Best regard's.