5 Replies Latest reply on May 7, 2008 8:33 AM by Paida Kumar

    Oracle Datasource not bound to JNDI

    Rainald Suchan Newbie

      Hi,

      I am using JBoss 4.0.2 and want to configure a Datasource to an Oracle Database with JNDI. When I run my application I get the following error:
      javax.naming.NameNotFoundException: OracleDS not bound

      In my session bean I get the Datasource like this:

      InitialContext ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup("OracleDS");
      Connection conn = ds.getConnection();

      I have the Oracle JDBC driver ojdbc14.jar in the directory jboss-4.0.2\server\default\lib

      My ejb-jar.xml looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar>
      DBManager
      <display-name>DBManager</display-name>
      <enterprise-beans>
      <!-- Session Beans -->

      <display-name>DBManagerEJB</display-name>
      <ejb-name>DBManagerEJB</ejb-name>
      dbmanager.DBManagerHome
      dbmanager.DBManager
      <ejb-class>dbmanager.DBManagerEJB</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <resource-ref>
      <res-ref-name>jdbc/OracleDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>

      </enterprise-beans>
      <assembly-descriptor>
      </assembly-descriptor>
      </ejb-jar>

      My jboss.xml looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">


      <enterprise-beans>

      <ejb-name>DBManagerEJB</ejb-name>
      <jndi-name>ejb/DBManagerEJB</jndi-name>
      <resource-ref>
      <res-ref-name>jdbc/OracleDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <jndi-name>java:OracleDS</jndi-name>
      </resource-ref>

      </enterprise-beans>
      <resource-managers>
      </resource-managers>


      The file oracle-ds.xml in the directory jboss-4.0.2\server\default\deploy looks like this:

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

      <local-tx-datasource>
      <jndi-name>OracleDS</jndi-name>
      <connection-url>jdbc:oracle:thin:@lahn.test.esri-de.net:1521:krb73</connection-url>
      <!--
      See on WIKI page below how to use Oracle's thin JDBC driver to connect with enterprise RAC.
      -->
      <!--
      Here are a couple of the possible OCI configurations.
      For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm

      <connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url>
      or
      <connection-url>jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url>

      Clearly, its better to have TNS set up properly.
      -->
      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      <user-name>krb</user-name>
      krb
      <min-pool-size>5</min-pool-size>
      <max-pool-size>100</max-pool-size>
      <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
      <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
      <!-- Checks the Oracle error codes and messages for fatal errors -->
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
      <!-- sql to call when connection is created
      <new-connection-sql>some arbitrary sql</new-connection-sql>
      -->
      <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
      <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
      -->
      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

      <type-mapping>Oracle9i</type-mapping>

      </local-tx-datasource>



      Does anybody have an idea what I do wrong or what I am missing?