Skip to main content

JAXP : using thread context class loader (null) for search.

2 replies [Last post]
Joined: 2008-07-08

I am new to Java. I have a class that uses jaxp for XML processing.
It works fine on windows with both jdk1.5 and jdk 1.6
On Mac side with (Apple's jdk 1.5) it does not.
when i set the debug property to true, I found the following differences in the log

On Windows
JAXP: using thread context class loader (sun.misc.Launcher$AppClassLoader@a39137) for search
JAXP: Looking up system property 'javax.xml.xpath.XPathFactory:'

JAXP: using thread context class loader (null) for search
JAXP: Looking up system property 'javax.xml.xpath.XPathFactory:'

the class loader is null on MAC Side.

Does any one encountered this before?.
How can i solve this problem?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-08-21

We ran into this problem moving code from 10.4 to Leopard.

When you use [b]-XstartOnFirstThread[/b] as a java -Xarg on Leopard, your ContextClassloader gets set to null.
This doesn't happen in 10.4 or with Windows or Linux flavors.

You can verify this in your code by outputting the value of:
If it is null, any libraries (including several of the Sun packages) that depend on using the ClassLoader can fail in strange ways.

Here's a workaround:
In the main method of your main class, do this first (assuming here your class is called [i]Main[/i]):

class [i]Main[/i] {
    public static void main(String[] args) {

This will set your ContextClassLoader to the default Java ClassLoader. (If you use custom ClassLoaders, you'll have to figure something else out).
It's essential to do this before you spawn child processes, because they inherit their parent Thread's ClassLoader.

Joined: 2004-12-15

I think Apple maintains their own JDK on MAC. In Sun's JDK, the bootclassloader is represented as null. If it's the same on MAC, JAXP shouldn't have trouble loading a class.

What's the error you're getting?