My Oracle Support Banner

Different Behavior of the Thread Context Classloader with JDK 1.4 and JDK 1.5 (Doc ID 453373.1)

Last updated on MAY 04, 2021

Applies to:

Oracle Containers for J2EE - Version to [Release AS10gR3]
Information in this document applies to any platform.


Using JDK 1.4 and JDK 1.5 with OC4J or leads to different results:

There is a different behavior of the Thread Context ClassLoader with different versions of JDK.

With JDk 1.5, Thread Context ClassLoader (received from Thread.currentThread().getContextClassLoader()) in all threads is the same ClassLoader instance as the current ClassLoader (received from getClass().getClassLoader()).

With JDK 1.4, Thread Context ClassLoader (in the threads, created by application) is NOT the same ClassLoader instance as the current ClassLoader. It is even the instance of a different Class.

You can reproduce the issue by running the “TestLoaders” Web Application.

This application has Start-up Servlet, creates one thread and one Timer Task.

It has three “check points” :
– in Start-up Servlet (thread created by OC4J)
- in the Tread (created by our application)
- in the Timer Task

At each point it is checking if Thread Context ClassLoader is the same ClassLoader instance as the current ClassLoader and printing Class Loaders (including “parents”).

In addition it checks if the correct parser is accessed (should be xerces, which is in the Web App classpath and for which we added a shared library).

Download the testcase(rename to .war) by clicking here


1. Start OC4J from the command line:

java -Xms128m -Xmx1024m -jar oc4j.jar -userThreads

2. Create a shared library xerces to use a xerces parser, as it is recommended by Oracle to use this parser
(Example: Replacing the Oracle XML Parser with the Xerces Parser -

3. Deploy TestLoaders.war.

During deployment for Web Module set (using console or by files modification):
<web-app-class-loader search-local-classes-first="true" />, <remove-inherited name="oracle.xml"/>, <import-shared-library name="xerces"/>


**AS CAN BE SEEN, oracle.xml.jaxp.JXDocument BuilderFactory@181efb9 IS PICKED UP INSTEAD OF org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@17a0b4d**


To view full details, sign in with your My Oracle Support account.

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

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.