ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From v...@trilogy.com
Subject Re: Class org/xml/sax/InputSource violates loader constraints
Date Tue, 28 Aug 2001 16:12:00 GMT
A look at the latest jUnit (v3.7 ?) sources reveals that jUnit's 
classloader fails to use the correct Java 2 classloader delegation 
pattern. Instead of delegating to the parent classloader, whichever that 
might be, jUnit always delegates to the application classloader (through 
findSystemClass()). This is guaranteed to cause problems when jUnit is 
loaded by anything other the standard application classloader -- precisely 
the case when junit task is not forked by Ant, I believe. 
Specifically, because Ant's install does not require lib/crimson.jar to be 
added to CLASSPATH or -classpath [namespace managed by the application 
classloader], it must be true that all classes in  lib/ are loaded by 
Ant's own classloader (including org.xml.sax.InputSource). If the user 
installed another jar containing SAX classes in <jdk home>/jre/lib/ext the 
following scneario may happen:

- junit code needs to access SAX classes;
- junit asks its own classloader for those and the classloader delegates 
to the application classloader, which delegates to its parent, extension 
classloader [note that this completely bypasses Ant's classloader];
- we thus have two different classloaders acting as defining classloaders 
for the same SAX classes. It would have worked in Java 1.1 but in Java 2 
this is precisely the 'violation of classloader constraints' problem that 
can be so hard to debug.

This is clearly a bug/flaw in jUnit framework and should be logged as 
such. I am a novice Ant user but I helped a co-worker track a 
classloader-related problem with Ant some months ago. At the time Ant had 
a similar problem with classlaoder delegation but I noticed that 1.4beta2 
implementation was fixed. If jUnit classloader gets fixed as well, the two 
may actually work together inside the same JVM instance...

Vlad.



Please respond to ant-user@jakarta.apache.org
To:     <ant-user@jakarta.apache.org>
cc: 

Subject:        Re: Class org/xml/sax/InputSource violates loader constraints


You will need to fork your junit task.

Conor

----- Original Message -----
From: "Atherton Richard - Z9V" <richard.atherton@AXA-RoyaleBelge.be>
To: <ant-user@jakarta.apache.org>
Sent: Tuesday, August 28, 2001 11:52 PM
Subject: Class org/xml/sax/InputSource violates loader constraints


>
> I am using the Ant Junit task, running a single suite using the textui.
Has
> anybody come across the following when using the Ant Junit task? Either
the
> Ant or the JUnit class loader seems to be complaining about the
InputSource
> class inside 'xerces.jar'. (We get the problem when using the JUnit 
Swing
> GUI outside of Ant, which has a dynamic class loader).
>
> Cheers,
> Richard.
>





Mime
View raw message