Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Eclipse, Ant and Leopard Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eclipse, Ant and Leopard Problem




It took me weeks to discover what the fix for this problem was since there were many complaints about it but no one posted a solution. I found this in a thread about class path problems in other areas.

It appears that the thread context class loader is not initialized correctly in all cases in the java environment shipped with Leopard. When it is not, the JDOM code does not get the benefit of your classpath and fails when loading the parser. (startOnFirstThread is a part of it)

If you add the following incantation to your main (before the first thread is launched) it will fix most cases.

        ClassLoader scl = ClassLoader.getSystemClassLoader();
        Thread t = Thread.currentThread();
        ClassLoader cl = t.getContextClassLoader();
        if (cl == null) {
            t.setContextClassLoader(scl);
        }

In addition, if you load any XML in static class initializations, you will need to insert the snippet prior to doing so. It may be sufficient to do that exclusively (in a static initialization) since they should run before main but I have not tried it.

Once set in a given thread, the class loader is inherited by any children of the one so modified.

I hope I don't hear anyone saying "works as intended", but I am not holding my breath.

John Brisbin

Nathan Moon wrote:
I have had a similar issue since migrating to Leopard.  What I was seeing is that I can't run any JUnit test through eclipse.  I get the same error about SAXParserFactoryImpl.

I am just offering guesses since I haven't had a whole lot of time to dedicate to solving the issue, but it seems to be related to -XstartOnFirstThread.  

The reason I have come to that hypothesis is because I found out that if I ran a JUnit test through eclipse, then pulled the command-line for the test run (using ps in the terminal), -XstartOnFirstThread was on the command-line.  If I just remove that flag and run the same command from the terminal, it runs fine.

The only piece of info I found online (I haven't searched in a while) was this message from the eclipse mailing lists:  http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg37971.html

That person thinks -XStartOnFirstThread causes problems with classloaders in Leopard.

nathan

On Feb 13, 2008, at 10:39 AM, email@hidden wrote:

Hello,

I realize this is truly an Eclipse issue, but I thought I might shoot the problem here as I know there are a lot of Eclipse users here.

I'm having trouble building a project using an external Ant and Eclipse.  Builds  
fine in Tiger, doesn't on Leopard.  When I try to build the project I  
get this error:

BUILD FAILED
XML parser factory has not been configured correctly: Provider  
org.apache.xerces.jaxp.SAXParserFactoryImpl not found

I've set Ant Home to be /Library/Bea/weblolgic92/server (just as I did  
on Tiger).  I have verified that SAXParserFactoryImpl resides in  
weblogic.jar and weblogic.jar is part of the Ant classpath.  I can  
build the project via the command line by navigating to the project  
directory, use the external ant to build by:

/Library/Bea/weblogic92/server/bin/ant build-all

and the project will build perfectly.  Also, this must be a Leopard  
thing because the same configuration builds just fine in Eclipse on  
Tiger (same Eclipse version, same WebLogic version).  Does anyone have  
any suggestions?

Thanks in advance.
Matt

10.5.1
Eclipse 3.4M4
WebLogic 9.2 



_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Eclipse, Ant and Leopard Problem (From: Nathan Moon <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.