#108 ClassNotFoundException after update to 2.x

Version 2.0.1
closed-fixed
nobody
JaCoCo (32)
5
2014-08-14
2012-01-03
Rainer Weinhold
No

Since a update to eclemma 2.x (2.0.1 to be exact) i cannot cover oracle projects, because of : "java.lang.ClassNotFoundException: oracle.security.pki.OracleWallet"

It seems like the new eclemma is now 'preloading' all classes (http://info.michael-simons.eu/?s=oraclesecretstore), but there is actually no OracleWallet. (And it is not needed) So this will fail. The normal Classloader as well as the old eclemma one, didn't have this problem.

Btw, the Workaround: just create a empty "oracle.security.pki.OracleWallet" Class. In case of the Oracle driver i can live with that workaround, because it's only one class. But i guess there are other libraries with similar effects and a whole bunch of missing classes.

driver : 10.2.0.3.0 -> ojdbc14-10.2.0.3.0.jar
Java : 1.6.0_17 (Sun)
eclemma : 2.0.1
eclipse : latests, indigo sr1
OS : windows 7, x64

TRACE:
Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
java.lang.NoClassDefFoundError: oracle/security/pki/OracleWallet
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1415)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
[...]
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NoClassDefFoundError: oracle/security/pki/OracleWallet
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1415)
... 87 more
Caused by: java.lang.ClassNotFoundException: oracle.security.pki.OracleWallet
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
... 90 more

Discussion

  • When looking at the Oracle driver class files there actually is a indirect dependency to the missing class:

    oracle.jdbc.OracleDriver extends oracle.jdbc.driver.OracleDriver which in turn has several methods with local variables of type oracle.security.pki.OracleWallet.

    But still no clue why this is only a problem when the JaCoCo agent instrumented the driver classes.

     
  • Marc Steffens pointed out, that this problem seems to be JaCoCo version specific. A detailed analysis reveals that the problem happens with JaCoCo 0.5.1 or younger:

    0.4.1 ok
    0.5.0 ok
    0.5.1 CNFE
    0.5.2 CNFE
    0.5.3 CNFE
    0.5.4 CNFE
    0.5.5 CNFE

    With 0.5.1 I reworked the way how probes for conditional jumps are inserted to guarantee correct stack map frames. The class files in question have version 1.2, so stack map frames shouldn't be inserted here. But anyways, with 0.5.1 the resulting control structures have changed.

     
    • labels: --> JaCoCo
     
  • With JaCoCo 0.5.8-SNAPSHOT the instrumentation strategy has been reworked and the ClassNotFoundException does not occur anymore.

     
  • This problem has been resolved with the latest JaCoCo 0.5.8-SNAPSHOT build. The next EclEmma release will then ship with the fixed JaCoCo version.

     
    • status: open --> closed-fixed
     
  • Fixed in EclEmma 2.1.3.