ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject FW: Problem with ANT classloader?
Date Fri, 17 May 2002 19:35:44 GMT
Don't any of the ANT experts out there have any clue what's going on here?

-----Original Message-----
From: Dominique Devienne [] 
Sent: Friday, May 17, 2002 12:07 PM
To: 'Ant Users List'
Subject: RE: Problem with ANT classloader?

I'm not creating any class loader, just using Class.forName(). I used to do
it Class.forName(classname, false, getSystemClassLoader()), but then when
run in-ant-process, this failed because I was running under the
AntClassLoader, not the system class loader (Does ant install it's class
locader as the Thread context class loader?). I changed my code to use the
same loader as the one that loaded the class that does the Class.forName
call (the AntCL in my case), and that's when the LinkageError crops in.

Of course I run with fork="true" to turn around that, but it's just slower.
I'd like to understand why I get this behavior in-ant-process!!!! --DD

-----Original Message-----
From: Ian Atkin [] 
Sent: Friday, May 17, 2002 12:02 PM
To: Ant Users List
Subject: Re: Problem with ANT classloader?

i get different but similar problems:-
- doing XSLT transforms with extension elements in them
- get similar complaints but it's a SAX class that offends

i think this is down to non-Ant code doing it's own class loading
- Ant has already loaded the class, client or 3rd party code then goes 
and loads it again
- if in-process this changes the loaded class, so when it's next used 
the JVM throws a LinkageError
- but i'm not sure so I'm going to read the lang spec again

i've always simply used fork=true on the <javac> to get round these troubles

must have run it in-process?


-----Original Message-----
From: Dominique Devienne [] 
Sent: Friday, May 17, 2002 11:09 AM
To: ''
Subject: Problem with ANT classloader?

I have a problem with ANT 1.4.1 running a Java class without forking that
does Class.forName calls. I include 3 outputs (while I'm at it, I also
include the build.xml which is simple) of the register target running with
fork="false" (FAILS), with fork="true" (SUCCEEDS), with fork="false" (FAILS)
in ANT debug mode for the gory details. The Java program I'm using uses the
DOM to load XML resource files. When running in-process with ANT, it
generates the following LinkageError:
java.lang.LinkageError: loader constraints violated when linking
org/w3c/dom/Document class
I'm running JDK 1.4 on Win2K, which now contains plenty of XML stuff. I thus
checked %ANT_HOME%\lib to see if I didn't have duplicate XML stuff, and I
did (parser.jar, jaxp.jar, crimson.jar). I checked the JDK's rt.jar, and it
seems to contain all the classes in these other jars, so I just plain
removed them from %ANT_HOME%\lib. ANT seems to work fine, except I still get
the same linkage error. Isn't AntClassLoader properly delegating to it's
parent classloader, ultimately going down all the way to the bootstrap class
loader to find the DOM's Document in rt.jar????
At this point, I'm stumped. ANT experts out there, please HELP. Regards,

========== build.xml ===========
<?xml version="1.0"?>
<project name="mowi" default="jar" basedir=".">
  <property environment="env" />
  <property name="lib"     location="lib" />
  <property name="classes" location="${lib}/classes" />
  <property name="jarfile" location="${lib}/com_lgc_${}.jar"
  <path id="classpath-default">
    <pathelement location="${classes}" />
    <fileset dir="${lib}" includes="**/*.jar" />
    <fileset dir="${env.DS_HOME}" includes="**/*.jar, **/*.zip" />
  <target name="init">
    <mkdir dir="${classes}" />
  <target name="classes"
          description="Compiles all Java sources">
    <javac srcdir="src"
           classpathref="classpath-default" />
  <target name="register"
          description="Registers all Appworks components">
    <mkdir dir="${classes}/META-INF" />
    <java classname=""
      <classpath refid="classpath-default" />
      <sysproperty key="com.lgc.infra.pres.ignoreRegistrationInfo"
                   value="true" />
      <sysproperty key="reginfo.filename"
      <sysproperty key="reginfo.searchpath"
                   value="${classes}" />
  <target name="compile" depends="register" />
  <target name="jar"
          description="Jars up all classes into mowiai.jar">
    <jar jarfile="${jarfile}" basedir="${classes}" />
  <target name="clean"
          description="Deletes Java classes and jar file">
    <delete dir="${classes}" quiet="true" />
    <delete file="${jarfile}" quiet="true" />

========== fork="false" ===========
P:\com_lgc\acme>%DS_HOME%\tools\ant\bin\ant -emacs register
Buildfile: build.xml
Scanning searchpath for components to register...
Found 5 components (1406 ms)
P:\com_lgc\acme\build.xml:39: java.lang.LinkageError: loader constraints
violated when linking org/w3c
/dom/Document class
Total time: 7 seconds
P:\com_lgc\acme>gvim build.xml

========== fork="true" ===========
P:\com_lgc\acme>%DS_HOME%\tools\ant\bin\ant -emacs register
Buildfile: build.xml
Scanning searchpath for components to register...
Found 5 components (1047 ms)
REGISTER SERVICE name  TetMeshAppletAdapter
REGISTER SERVICE class com.lgc.mowi.viz.acme.TetMeshAppletAdapter

Total time: 19 seconds
========== fork="false" -debug ===========

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

View raw message