i have a naven application in which i use Birt 4.6. Below my dependencies.
<dependency>
<groupId>org.eclipse.birt.ojdbc</groupId>
<artifactId>odajdbc</artifactId>
<version>4.6.0-201606072122</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.6.0-20160607</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.apache.xerces</artifactId>
</exclusion>
<exclusion>
<artifactId>org.apache.poi</artifactId>
<groupId>org.eclipse.birt.runtime</groupId>
</exclusion>
</exclusions>
</dependency>
I am able to connect with the database and generate the reports. Those are the good news.
Unfortunately, i noticed in my log file that there is an exception thrown. The exception can seen below
2017-01-10 14:57:15,446 SEVERE [org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager] (default task-6) DriverClassLoader failed to load class: oracle.jdbc.driver.OracleDriver: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver at org.eclipse.birt.core.framework.URLClassLoader.findClass1(URLClassLoader.java:188) at org.eclipse.birt.core.framework.URLClassLoader$1.run(URLClassLoader.java:156) at org.eclipse.birt.core.framework.URLClassLoader$1.run(URLClassLoader.java:1) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.birt.core.framework.URLClassLoader.findClass(URLClassLoader.java:151) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.loadExtraDriver(JDBCDriverManager.java:1064) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.findDriver(JDBCDriverManager.java:859) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.loadAndRegisterDriver(JDBCDriverManager.java:986) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.loadAndRegisterDriver(JDBCDriverManager.java:958) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.doConnect(JDBCDriverManager.java:285) at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.getConnection(JDBCDriverManager.java:236) at org.eclipse.birt.report.data.oda.jdbc.Connection.connectByUrl(Connection.java:254) at org.eclipse.birt.report.data.oda.jdbc.Connection.open(Connection.java:163) at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection.open(OdaConnection.java:250) at org.eclipse.birt.data.engine.odaconsumer.ConnectionManager.openConnection(ConnectionManager.java:165) at org.eclipse.birt.data.engine.executor.DataSource.newConnection(DataSource.java:224) at org.eclipse.birt.data.engine.executor.DataSource.open(DataSource.java:212) at org.eclipse.birt.data.engine.impl.DataSourceRuntime.openOdiDataSource(DataSourceRuntime.java:217) at org.eclipse.birt.data.engine.impl.QueryExecutor.openDataSource(QueryExecutor.java:437) at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:325) at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQuery.java:463) at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.produceQueryResults(PreparedDataSourceQuery.java:190) at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:178) at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery.execute(PreparedOdaDSQuery.java:179) at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.execute(DataRequestSessionImpl.java:651) at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:152) at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:286) at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1947) at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80) at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62) at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43) at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46) at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65) at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92) at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:181) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
For some reason the JDBCDriverManager struggles to find the correct driver, throws the exception , finally finds the driver connects to the database and generates the report.
I did a debug on JDBCDriverManager and hope that the information below does help a bit.
- The app goes through the doConnect() function JDBCDriverManager. Inside there the Connection getJndiDSConnection( driverClass, jndiNameUrl, connectionProperties ); returns null . Same happens for the getJndiDSConnection in the doConnect. also returns null
- Then the loadAndRegisterDriver( driverClass, driverClassPath ); is called with following arguments oracle.jdbc.driver.OracleDriver and null
- Inside the loadAndRegisterDriver the findDriver( className, driverClassPath, refreshClassLoader ) is called with following arguments oracle.jdbc.driver.OracleDriver , null, false
- On the next step driverClass = loadExtraDriver( className, true, refresh, driverClassPath ); is called with oracle.jdbc.driver.OracleDriver , true , false , null which throws the ClassNotFoundException mentioned above.
- Final step, we are still inside findDriver method where the driver = this.getDriverInstance( driverClass, refresh ); method is called and finally returns oracle.jdbc.driver.OracleDriver .
After step 5 everything works fine. As i mentioned, the exception appears only one time and still the connection with the database is created and the reports are generated. After that, no matter how many times i create a report, the exception is never thrown again.
I would like here to add some further info about the findDriver method. This method tries in several ways to get the driver. First is
// Driver not in plugin class path; find it in drivers directory
driverClass = loadExtraDriver( className, true, refresh, driverClassPath );
Which returns null and then gives a try to get the driver from the context
driverClass = Class.forName( className, true, Thread.currentThread( ).getContextClassLoader());
This times it finally achieves to retrieve the driver.
What am i missing? It is clear that it cannot load it from the plugins since i do not have any plugins directory. Is there a way to overcome this exception ?
As Mark mentioned, there was no need to add as a dependency the org.eclipse.birt.ojdbc . I stopped using the org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar and used my local ojdbc driver.
The above fixes the exception we get on the first try to load the driver.