Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Upgrade to ojdbc7.jar: java.lang.NoClassDefFoundError: oracle/security/pki/OraclePKIProvider

978346Sep 3 2013 — edited Oct 15 2014

My applications compiles and runs fine with JDK 7. It was using ojdbc6.jar, ucp.jar and the JDBC thin client without any problem.

I tried to upgrade to the new ojdbc7.jar and ucp.jar but I cannot get it to start; it complains about a missing class :

java.lang.NoClassDefFoundError: oracle/security/pki/OraclePKIProvider

  at java.lang.Class.forName0(Native Method)

  at java.lang.Class.forName(Class.java:270)

  at oracle.ucp.jdbc.PoolDataSourceImpl.initConnectionFactory(PoolDataSourceImpl.java:2352)

  at oracle.ucp.jdbc.PoolDataSourceImpl.createUniversalConnectionPool(PoolDataSourceImpl.java:831)

  at oracle.ucp.admin.UniversalConnectionPoolManagerBase.createConnectionPool(UniversalConnectionPoolManagerBase.java:537)

  at oracle.ucp.admin.UniversalConnectionPoolManagerMBeanImpl.createConnectionPool(UniversalConnectionPoolManagerMBeanImpl.java:303)

  at oracle.ucp.jdbc.PoolDataSourceImpl.startPool(PoolDataSourceImpl.java:667)

  at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1034)

  at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:985)

  at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:966)

Any idea about what's wrong and how to fix this?

Thanks

This post has been answered by 978346 on Sep 5 2013
Jump to Answer

Comments

unknown-7404
Any idea about what's wrong and how to fix this?

Yes - add the missing jar file to your classpath.

The exception means that it cannot find that file on the classpath or in any of the jars on the classpath.

So you are likely using a different classpath that you were using before and the appropriate '---oraclepki---' jar file is either not on that classpath or is now missing.

978346

Nope, no change in the classpath. Only upgrade to ojdbc7.jar and new ucp.jar.

Further investigation shows that ojdbc7.jar loads OraclePKIProvider class (and fails) whereas ojdbc6.jar handles gracefully the case when this class is missing.

I had to include manually oraclepki.jar from OC4J. In other words, you cannot use oracle.jdbc.driver.OracleDriver from ojdbc7 without OC4J.

unknown-7404
Further investigation shows that ojdbc7.jar loads OraclePKIProvider class (and fails) whereas ojdbc6.jar handles gracefully the case when this class is missing.

I had to include manually oraclepki.jar from OC4J. In other words, you cannot use oracle.jdbc.driver.OracleDriver from ojdbc7 without OC4J.

You should NOT be using 'oracle.jdbc.driver.OracleDriver' class in your code to begin with.

Use the 'oracle.jdbc.OracleDriver' class.

And ojdbc7 works just fine without OC4J.

You may have something in your UCP or JDBC configuration that indicates that an Oracle keystore should be configured. You may not have noticed it before if the previous driver did not complain and you did not really need that class.

So it could just be a bug fix.

978346
Answer

A more thorough investigation indeed shows the problem is due to my environment. Let me explain...

I do use class oracle.jdbc.OracleDriver.

As soon as the class oracle.jdbc.OracleDriver is loaded, the NoClassDefFound exception is raised by the class initializer of oracle.jdbc.driver.OracleDriver (oracle.jdbc.OracleDriver inherits from oracle.jdbc.driver.OracleDriver). However, the OracleDriver static initializer code catches Throwable, so everything should be just fine.

In my case, the exception is not caught! How is this possible?

I discovered this is due to the JVM option -XX:-UseSplitVerifier I have to use to workaround an Hibernate problem (https://hibernate.atlassian.net/browse/HHH-7544): when this option is set, the NoClassDefFound exception is *not* caught within the class initializer!

Some people say using -XX:-UseSplitVerifier is perfectly safe with Java 7, but there is obviously one case where it is not! I could not reproduce the try/catch issue with a simple testcase, so I suspect the issue is due to the bytecode from ojdbc7.jar when it is run with the split verifier.


Testcase with ojdbc7.jar:


package foo.bar;

public class Test {

    public static void main(String[] args) {

        System.out.println("Try loading class oracle.jdbc.OracleDriver...");

        try {

            Class.forName("oracle.jdbc.OracleDriver");

            System.out.println("OK: class loaded!");

        } catch (Throwable e) {

            System.out.println("Error: exception caught!");

            e.printStackTrace();

        }

    }

}

With only this class and ojdbc7.jar in the current directory, run the following tests:

>java -cp ojdbc7.jar;. foo.bar.Test

Try loading class oracle.jdbc.OracleDriver...

OK: class loaded!

>java -XX:-UseSplitVerifier -cp ojdbc7.jar;. foo.bar.Test

Try loading class oracle.jdbc.OracleDriver...

Error: exception caught!

java.lang.NoClassDefFoundError: oracle/security/pki/OraclePKIProvider

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Unknown Source)

        at foo.bar.Test.main(Test.java:6)

Caused by: java.lang.ClassNotFoundException: oracle.security.pki.OraclePKIProvider

        at java.net.URLClassLoader$1.run(Unknown Source)

        at java.net.URLClassLoader$1.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(Unknown Source)

        at java.lang.ClassLoader.loadClass(Unknown Source)

        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

        at java.lang.ClassLoader.loadClass(Unknown Source)

        ... 3 more

Marked as Answer by 978346 · Sep 27 2020
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 3 2013
Added on Sep 3 2013
4 comments
4,881 views