Shared Library Using JDBC Driver Directly, gets AnnotatedNoClassDefFoundError (Doc ID 414453.1)

Last updated on DECEMBER 05, 2016

Applies to:

Oracle Containers for J2EE - Version 10.1.3.0.0 to 10.1.3.5.0 [Release AS10gR3]
Information in this document applies to any platform.
***Checked for relevance on 22-Apr-2013***


Symptoms

Problem Statement:

On 10.1.3, a new application is trying to define a global jar file to be imported by multiple applications and for that it is defined as a shared library.

The jar file uses JDBC features and registers OracleDriver to get direct control of Datasources and JDBC connections

Expected Behaviour
The jar file should be defined as a shared library, and imported by any application.
The shared lib should be able to load JDBC driver correctly

Errors observed

In application.log for the application

07/01/31 14:32:07.376 <appname>: Servlet error oracle.classloader.util.AnnotatedNoClassDefFoundError:

Missing class: oracle.jdbc.driver.OracleDriver
Dependent class: <yourclassname>
Loader: global.libraries:1.0

Code-Source: /oracle10/as/j2ee/home/applib/<yourjarfile>
Configuration: <code-source> in /oracle10/as/j2ee/<instance>/config/server.xml


The missing class is available from the following locations:

1. Code-Source: /oracle10/as/jdbc/lib/ojdbc14dms.jar (from <code-source> (ignore manifest
Class-Path) in META-INF/boot.xml in /oracle10/as/j2ee/home/oc4j.jar)
This code-source is available in loader oracle.jdbc:10.1.0_2.

at oracle.classloader.PolicyClassLoader.handleClassNotFound (PolicyClassLoader.java:208) [/oracle10/as/j2ee/home/lib/pcl.jar (from system property java.class.path), by
sun.misc.Launcher$AppClassLoader@1482257]
at oracle.classloader.PolicyClassLoader.internalLoadClass (PolicyClassLoader.java:1679) [/oracle10/as/j2ee/home/lib/pcl.jar (from system property java.class.path), by
sun.misc.Launcher$AppClassLoader@1482257]
at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1635) [/oracle10/as/j2ee/home/lib/pcl.jar (from system property java.class.path), by
sun.misc.Launcher$AppClassLoader@1482257]
at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1620) [/oracle10/as/j2ee/home/lib/pcl.jar (from system property java.class.path),
by sun.misc.Launcher$AppClassLoader@1482257]
at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:319) [jre bootstrap, by jre.bootstrap:1.5.0_06]
at cmbc.DataSourceHandler.<init> (DataSourceHandler.java:21)
[/oracle10/as/j2ee/home/applib/cmbc.jar (from <code-source> in
/oracle10/as/j2ee/home/config/server.xml), by global.libraries:1.0]
at <package>.<class>.<method> (<classname>:<linenumber>)
[/oracle10/as/j2ee/home/applib/<yourjarfile> (from <code-source> in
/oracle10/as/j2ee/home/config/server.xml), by global.libraries:1.0]
at _index._jspService (_index.java:56)



Steps To Reproduce:
The issue can be reproduced at will with the following steps:
- start the container
- un-deploy the application
- put the jar file in the ./applib
- deploy the application
- test
- stop and start the container
- test again

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms