ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Linkage error with new jspc task
Date Wed, 09 Jan 2002 22:10:49 GMT
Loader constraint violations are usually caused by a situation in which 
two classloaders, if asked where they would get a class from, disagree 
about the location. This is typically brought to the front and causes an 
actual exception below when two classes loaded by distinct classloaders 
exchange data and usage of that data causes more classes to be loaded.

The best way to ensure this does not happen it to understand the 
classloader hierarchy (including all parent-child relationships)  for your 
runtime and make sure that every class has a unique defining classpath for 
it. This helps:

- do not use the CLASSPATH OS environment variable at all. There is no 
need and it causes more confusion then it aids, because you tend to forget 
about what's in it.

- do not keep anything in <jdk home>/jre/lib/ext. Period. The extensions 
are loaded by an extension classloader which sits between the bootstrap 
one and the application (-classpath) one and hence every extension is 
implicitly ahead of anything in the -classpath/CLASSPATH. This can cause 
issues with dynamic resource loading. [When a class does Class.forName() 
this will use the defining loader for the calling class and in the 
extension case this would be the extension classloader, one that does not 
even know about -classpath. Unless the code was written to anticipate 
that, this will cause problems. This has confused many a person already 
who installed jaxp.jar in jre/lib/ext and is why Sun had to add Thread 
context classloaders etc etc -- a whole separate topic, just don't do it.]

Note for IBM JDK users: the IBM JDK comes with a bunch of stuff 
pre-installed in the ext directory (an old version of xerces.jar, for 
example). Bad idea.

In essence, manage your classpath explicitly and you will be glad you did.

Please respond to "Ant Users List" <>

Subject:        Linkage error with new jspc task

Hi everyone,

I am using ant 1.5 alpha, to get access to the new jspc task.

However, I am running into the following error when I try and execute it:

C:\dev\kiosk\Design\Admin\build.xml:87: java.lang.LinkageError: loader 
ts violated when linking org/w3c/dom/Document class

Looking through the mailing list, it appears that Ant sometimes has 
trouble with
the task loader loading classes that have already been loaded eg with
crimson.jar and xerces.jar (see  The
suggestion there was to use fork="true" to get it to work, but this is not 
option with the jspc task.

Would REALLY appreciate any help on this one!  The new task will save 
time by selectively reprecompiling.  Do I need to replace crimson.jar with
something else?

Many thanks,


JSCP task:

<target name="jspc">
<jspc srcdir="${build.home}\jsp"
<include name="**/*.jsp" />
<pathelement location="${tomcat.home}\lib\jasper-runtime.jar"/>
<pathelement location="${tomcat.home}\lib\naming-factory.jar"/>
<pathelement location="${tomcat.home}\lib\jasper-compiler.jar"/>
<pathelement location="${tomcat.home}\common\lib\servlet.jar"/>
<pathelement location="${tomcat.home}\common\lib\xerces.jar"/>
<pathelement location="${src}\..\Common\jsp\Web-inf\lib\struts.jar"/>
<pathelement location="${build.home}\classes"/>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message