9 Replies Latest reply on Oct 22, 2007 1:26 PM by richardwilly98

    Problem in acessing Oracle data Source from JBoss 4

    jsbhangra

      Hello,

      I am trying to access Oracle data source in Jboss from a struts based web application. For doing this I have done the following:

      i am using Oracle 10g Express edition.

      (1) Copied the thin oracle driver (ojdbc14.jar) in server\default\lib directory of
      JBOSS_HOME.

      (2) Copied the oracle-ds.xml file from docs\examples\jca directory of JBOSS_HOME to
      server\default\deploy of JBOSS_HOME.
      which is :

      <local-tx-datasource>
      <jndi-name>oracleDS</jndi-name>
      <connection-url>jdbc:oracle:thin:@localhost:1521:XE</connection-url>
      <user-name>uname</user-name>
      pwd

      <type-mapping>OracleXE</type-mapping>

      </local-tx-datasource>



      (3) Next I have changed the default standardjaws.xml. I have changed the data source
      name and its type-mapping to OracleXE.

      i added type mapping for Oracle XE simply copeing the content of whole oracle 8 type mapping and just changed its name to OracleXE

      java:/oracleDS
      <type-mapping>OracleXE</type-mapping>
      false
      <default-entity>
      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>true</tuned-updates>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <row-locking>false</row-locking>
      <read-ahead>false</read-ahead>
      </default-entity>



      (4) I have changed standardjbosscmp-jdbc.xml file also.


      (5) I have put an entry in login-config.xml file also.


      But when i deploy my application
      these are the excpetions i get in my server log :---

      Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: oracle.jdbc.driver.OracleDriver

      Could not create deployment: ile:/usr/local/jboss-4.0.5.GA/server/default/deploy/oracle-ds.xml

      please help me out.. i am unable to figure out the problem.

      some more desciptive server log dump :
      14:05:45,430 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=oracleDS' to JNDI name 'java:oracleDS'
      14:05:45,512 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: oracle.jdbc.driver.OracleDriver; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: oracle.jdbc.driver.OracleDriver))
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:179)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:565)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:250)


      rg.jboss.resource.JBossResourceException: Failed to register driver for: oracle.jdbc.driver.OracleDriver; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: oracle.jdbc.driver.OracleDriver)
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.getDriver(LocalManagedConnectionFactory.java:287)
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:170)
      ... 122 more
      Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: oracle.jdbc.driver.OracleDriver
      at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)

      44 ERROR [GeneralPurposeDatabasePersistencePlugin] Cannot create timer table
      org.jboss.deployment.DeploymentException: Error while checking if table aleady exists TIMERS; - nested throwable: (org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: oracle.jdbc.driver.OracleDriver; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: oracle.jdbc.driver.OracleDriver)); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: oracle.jdbc.driver.OracleDriver; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: oracle.jdbc.driver.OracleDriver))))
      at org.jboss.ejb.plugins.cmp.jdbc.SQLUtil.tableExists(SQLUtil.java:1040)
      at org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin.createTableIfNotExists(GeneralPurposeDatabasePersistencePlugin.java:112)
      at org.jboss.ejb.txtimer.DatabasePersistencePolicy.startService(DatabasePersistencePolicy.java:95)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)

        • 1. Re: Problem in acessing Oracle data Source from JBoss 4
          vickyk

          Surprising , Can you please verify if the oracle.jdbc.driver.OracleDriver is present in the ojdbc14.jar ?
          If it is present then perform the following steps to trouble shoot the problem

          1) Configure the Oracle DS by making the changes in the oracle-ds.xml file and drop it in the deply directory .
          2) Copy the driver related jar file in the server\default\lib folder.

          3) Write a simple jsp which would try to get this connection.

          Also make sure that you restart Jboss if you have copied the driver related jar and configured oracle ds file while the Server was running .

          • 2. Re: Problem in acessing Oracle data Source from JBoss 4
            jsbhangra

            thanx vicky . for a quick reply..
            driver is alright as it connects the database with simple Class.fotName("url ")
            and DriverManager.getConnection()

            but i want to do it the Data source way.

            • 3. Re: Problem in acessing Oracle data Source from JBoss 4
              vickyk

              okay perform the simple test then which I have explained in earlier post .

              • 4. Re: Problem in acessing Oracle data Source from JBoss 4
                jsbhangra

                thanx again vicky it worked with the server ..
                i mean server log is clean withou tany exception it says it has boung my data source"


                but when i deploy my struts application :


                it gives exception

                javax.naming.NamingException: resource-ref: oracleDS has no valid JNDI binding. Check the jboss-web/resource-ref

                i tried it like this :
                my context.xml entry reads as :



                i tried for both "java:oracleDS" and "oracleDS" it gave same exception ...
                oracleDS has no valid JNDI binding.

                • 5. Re: Problem in acessing Oracle data Source from JBoss 4
                  jsbhangra

                  This is the server log enty telling datasource has been bound :

                  7,812 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=oracleDS' to JNDI name 'java:oracleDS'



                  Here is the exception i get when i run my web application :

                  javax.naming.NameNotFoundException: oracleDS not bound

                  • 6. Re: Problem in acessing Oracle data Source from JBoss 4
                    vickyk

                     

                    javax.naming.NameNotFoundException: oracleDS not bound

                    Can you write a new jsp with the following code snippet
                     InitialContext ctx = new InitialContext();
                     DataSource ds = (DataSource)ctx.lookup("java:oracleDS");
                     Connection con = ds.getConnection();

                    This should work ...
                    I am not sure how you are trying to get the DS in your web application , looks like the you are binding it in the resource ref tag of the web.xml .

                    • 7. Re: Problem in acessing Oracle data Source from JBoss 4
                      vickyk

                       

                      javax.naming.NamingException: resource-ref: oracleDS has no valid JNDI binding. Check the jboss-web/resource-ref

                      You should have
                      1)
                      <resource-ref>
                       <description>DB Connection</description>
                       <res-ref-name>oracleDS</res-ref-name>
                       <res-type>javax.sql.DataSource</res-type>
                       </resource-ref>
                      

                      The above stuff in the web.xml file of the web application

                      2)
                       <resource-ref>
                       <res-ref-name>oracleDS</res-ref-name>
                       <jndi-name>java:oracleDS</jndi-name>
                       </resource-ref>
                      

                      The above line should be in the jboss-web.xml

                      2) Now this should work
                      DataSource ds = (DataSource)ctx.lookup("oracleDS");
                      




                      • 8. Re: Problem in acessing Oracle data Source from JBoss 4
                        jsbhangra

                        Thanx a lot vicky
                        it worked at last . with code snippet u provided.

                        i was using this :

                         ctx=(Context)ic.lookup("java:comp/env");
                         ds=(DataSource)ctx.lookup("java:/oracleDS");
                         con=ds.getConnection();
                        


                        Now Can You tell me how to configure connection pooling ..?
                        what will be most effecient technique ..?
                        I am develop struts based web application . which will be hit be million of user's(as client said )

                        Jasdeep


                        • 9. Re: Problem in acessing Oracle data Source from JBoss 4
                          richardwilly98

                          I had the same issue using MS SQL 2005.
                          In mssql-ds.xml, connection-url DatabaseName seems to be case sensitive.