2 Replies Latest reply on Apr 8, 2005 12:51 PM by Vasudev Krishnamoorthy

    NameNotFound Exception when refering to DataSource in JBOSS

    Vasudev Krishnamoorthy Newbie

      Hi

      The following code gives a NameNotFoundException in JBOSS4.0 SP1.

      javax.naming.Context ctx = new javax.naming.InitialContext();
      javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:/xactly-dataSource-oraclePool");


      The Same code works in JBOSS 3.2.4.

      When I use the jndi view i see the datasource list in the java: namespace.

      I tried all options like without the java:/ and modifying the oracle-ds.xml to use-java-context false/true but i always get the NameNotFoundException.

      The code to lookup the DataSource is in a startup class and this works fine in JBoss3.2.4.

      Is it a bug in 4.0 sp1 or is it some other configuration

      //========== oracle-ds.xml File =============/

      <local-tx-datasource>
      <jndi-name>xactly-dataSource-oraclePool</jndi-name>
      <use-java-context>true</use-java-context>
      <connection-url>jdbc:oracle:thin:@localhost:1521:SWDB</connection-url>

      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      <user-name>xactly</user-name>
      xactly

      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>


      </local-tx-datasource>



        • 1. Re: NameNotFound Exception when refering to DataSource in JB
          Darran Lofthouse Master


          The code to lookup the DataSource is in a startup class and this works fine in JBoss3.2.4.


          At what point is the error occuring?
          Are you deploying the datasource first then deploying the service?
          Or are you deploying them both at the same time / restarting the server?

          When all deployed at the same time the service / startup class would be deployed first which could explain why the datasource is not bound when it is looked up.

          If this is the case in the deployment descriptor of the startup class you will need to specify that it depends on the datasource.

          • 2. Re: NameNotFound Exception when refering to DataSource in JB
            Vasudev Krishnamoorthy Newbie

            Hi,

            I am using a user-service.xml as a startup class. The datasource is specified in oracle-ds.xml and both the files are in the deploy directory. How do i specify the depends in the user-service.xml

            <?xml version="1.0" encoding="UTF-8"?>
            
            <!-- $Id: user-service.xml,v 1.4.2.1 2003/10/13 03:30:41 starksm Exp $ -->
            
            <!-- ===================================================================== -->
            <!-- -->
            <!-- User Service Configuration -->
            <!-- -->
            <!-- ===================================================================== -->
            
            <server>
            
             <classpath codebase="." archives="xstartup.jar"/>
            
            
            
             <mbean code="com.xactly.startup.XStartup"
             name="user:service=XStartup">
             </mbean>
            
            </server>