7 Replies Latest reply on Jul 20, 2016 9:52 AM by Wolfgang Mayer

    Application war not able to access db driver class from jboss jvm

    Ritesh negi Newbie

      Hi,

      We are using Jboss EAP 6.3.3.

      I have registered oracle driver as a module in jboss domain and I can see during the server startup, the module getting loaded.

      Now my application tries to use the class and I see the below error.

       

      Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver from [Module "deployment.test.war:main" from Service Module Loader]

       

      I am unable to figure out how my application can access the driver class registered with jboss jvm.

      Can someone please guide me on this?

        • 1. Re: Application war not able to access db driver class from jboss jvm
          Wolfgang Mayer Master

          Why does your appplication try to use this class? The access to the database is usually handled by the AS (eg via Hibernate)

          But you should also create a datasource and test the connection before using it in your application.

          • 2. Re: Application war not able to access db driver class from jboss jvm
            Wolf-Dieter Fink Master

            If you need to access the Oracle classes direct you need to add a dependency to the module you have created by using MANIFEST of jboss-deployment-structure.xml.

            See the ClassLoading documentation for EAP

            • 3. Re: Application war not able to access db driver class from jboss jvm
              Ritesh negi Newbie

              Our application is an IAM product, Sailpoint IIQ which we are moving to JBOSS from Websphere.

              IIQ has applications configured to talk to various systems, one of which is a oracle DB for which the application inside IIQ needs to refer to the db driver class to connect to the target DB.

              I did add the dependency in jboss-deployment-structure.xml as below.

               

                  <dependencies>

                    <system export="true">

                      <paths>

                        <path name="net/sourceforge/jtds/main"/>

                        <path name="com/oracle/jdbc/main"/>

                      </paths>

                    </system>

                  </dependencies>

               

              this did not help.

              • 4. Re: Application war not able to access db driver class from jboss jvm
                Wolf-Dieter Fink Master

                You should not add dependencies with <path>

                if you have a module you should use

                  <module name="com.oracle.jdbc"/>

                inside of teh dependencies element

                • 5. Re: Application war not able to access db driver class from jboss jvm
                  jaikiran pai Master

                  Ritesh negi wrote:

                   

                  Our application is an IAM product, Sailpoint IIQ which we are moving to JBOSS from Websphere.

                  IIQ has applications configured to talk to various systems, one of which is a oracle DB for which the application inside IIQ needs to refer to the db driver class to connect to the target DB.


                   

                  Can you post the entire exception stacktrace you are seeing?

                   

                  Also, do you use a DataSource to obtain the connection or do you really directly talk to the JDBC driver? Any relevant code that you can paste here?

                  • 6. Re: Application war not able to access db driver class from jboss jvm
                    Ritesh negi Newbie

                    Hi Wolf-Dieter Fink,

                    I did add the module as dependency as you suggested and the earlier error is no more but I am getting a different error..

                     

                    Hi Jaikiran,

                     

                    Here is the complete stack for the latest error after adding of modules as dependencies.

                     

                    2016-07-20 01:33:00,951 sailpoint.tools.GeneralException: could not insert: [sailpoint.object.TaskResult]

                            at sailpoint.persistence.HibernatePersistenceManager.commitTransaction(HibernatePersistenceManager.java:496)

                            at sailpoint.persistence.ClassPersistenceManager.commitTransaction(ClassPersistenceManager.java:207)

                            at sailpoint.server.InternalContext.commitTransaction(InternalContext.java:501)

                            at sailpoint.api.TaskManager.saveQualifiedResult(TaskManager.java:1307)

                            at sailpoint.api.TaskManager.createResult(TaskManager.java:1176)

                            at sailpoint.api.TaskManager.runSync(TaskManager.java:744)

                            at sailpoint.scheduler.JobAdapter.execute(JobAdapter.java:127)

                            at org.quartz.core.JobRunShell.run(JobRunShell.java:202)

                            at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

                    Caused by: org.hibernate.exception.GenericJDBCException: could not insert: [sailpoint.object.TaskResult]

                            at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)

                            at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)

                            at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)

                            at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2438)

                            at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2858)

                            at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)

                            at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)

                            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)

                            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)

                            at sailpoint.persistence.PatchedDefaultFlushEventListener.performExecutions(PatchedDefaultFlushEventListener.java:39)

                            at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)

                            at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)

                            at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)

                            at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)

                            at sailpoint.persistence.HibernatePersistenceManager.commitTransaction(HibernatePersistenceManager.java:482)

                            ... 8 more

                    Caused by: java.sql.SQLException: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection

                            at sailpoint.tools.JdbcUtil.setOracleCLOBParameter(JdbcUtil.java:271)

                            at sailpoint.persistence.XmlType.nullSafeSet(XmlType.java:310)

                            at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:173)

                            at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2168)

                            at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2414)

                            ... 19 more

                    QuartzScheduler_Worker-3 ERROR sailpoint.api.TaskManager:1309 - Unable to save task result with unique value: could not insert: [sailpoint.object.TaskResult]

                    sailpoint.tools.GeneralException: could not insert: [sailpoint.object.TaskResult]

                            at sailpoint.persistence.HibernatePersistenceManager.commitTransaction(HibernatePersistenceManager.java:496)

                            at sailpoint.persistence.ClassPersistenceManager.commitTransaction(ClassPersistenceManager.java:207)

                            at sailpoint.server.InternalContext.commitTransaction(InternalContext.java:501)

                            at sailpoint.api.TaskManager.saveQualifiedResult(TaskManager.java:1307)

                            at sailpoint.api.TaskManager.createResult(TaskManager.java:1176)

                            at sailpoint.api.TaskManager.runSync(TaskManager.java:744)

                            at sailpoint.scheduler.JobAdapter.execute(JobAdapter.java:127)

                            at org.quartz.core.JobRunShell.run(JobRunShell.java:202)

                            at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

                    Caused by: org.hibernate.exception.GenericJDBCException: could not insert: [sailpoint.object.TaskResult]

                            at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)

                            at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)

                            at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)

                            at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2438)

                            at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2858)

                            at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)

                            at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)

                            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)

                            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)

                            at sailpoint.persistence.PatchedDefaultFlushEventListener.performExecutions(PatchedDefaultFlushEventListener.java:39)

                            at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)

                            at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)

                            at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)

                            at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)

                            at sailpoint.persistence.HibernatePersistenceManager.commitTransaction(HibernatePersistenceManager.java:482)

                            ... 8 more

                    Caused by: java.sql.SQLException: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection

                            at sailpoint.tools.JdbcUtil.setOracleCLOBParameter(JdbcUtil.java:271)

                            at sailpoint.persistence.XmlType.nullSafeSet(XmlType.java:310)

                            at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:173)

                            at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2168)

                            at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2414)

                            ... 19 more

                    • 7. Re: Application war not able to access db driver class from jboss jvm
                      Wolfgang Mayer Master

                      If you don't neither use JPA nor Hibernate you could of course use the pure JDBC connection approach.

                      So it should also work in WildFly if you just add the path to your driver via

                       

                      String oracleHome = System.getenv("ORACLE_HOME");

                      URL Driverurl = new File(oracleHome + "/jdbc/lib/ojdbc6.jar").toURI().toURL();

                       

                      and then load your driver via the URLClassLoader like

                       

                      URLClassLoader cl = new URLClassLoader(new URL[]{Driverurl});

                      Class<?> c = cl.loadClass("oracle.jdbc.driver.OracleDriver");

                      driver = (Driver) c.newInstance();