Don't any of the ANT experts out there have any clue what's going on here? --DD
-----Original Message----- From: Dominique Devienne [mailto:[EMAIL PROTECTED] 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 [mailto:[EMAIL PROTECTED] 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? Ian -----Original Message----- From: Dominique Devienne [mailto:[EMAIL PROTECTED] Sent: Friday, May 17, 2002 11:09 AM To: '[email protected]' Subject: Problem with ANT classloader? Hi, 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, --DD ========== 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_${ant.project.name}.jar" /> � <path id="classpath-default"> ��� <pathelement location="${classes}" /> ��� <fileset dir="${lib}" includes="**/*.jar" /> ��� <fileset dir="${env.DS_HOME}" includes="**/*.jar, **/*.zip" /> � </path> � <target name="init"> ��� <mkdir dir="${classes}" /> � </target> � <target name="classes" ��������� depends="init" ��������� description="Compiles all Java sources"> ��� <javac srcdir="src" ���������� source="1.4" ���������� destdir="${classes}" ���������� deprecation="on" ���������� classpathref="classpath-default" /> � </target> � <target name="register" ��������� depends="classes" ��������� description="Registers all Appworks components"> ��� <mkdir dir="${classes}/META-INF" /> ��� <java classname="com.lgc.infra.pres.services.RegistrationInfoCreator" ��������� fork="false"> ����� <classpath refid="classpath-default" /> ����� <sysproperty key="com.lgc.infra.pres.ignoreRegistrationInfo" ������������������ value="true" /> ����� <sysproperty key="reginfo.filename" ������������������ value="${classes}/META-INF/AppworksRegistration.xml" /> ����� <sysproperty key="reginfo.searchpath" ������������������ value="${classes}" /> ��� </java> � </target> � <target name="compile" depends="register" /> � <target name="jar" ��������� depends="compile" ��������� description="Jars up all classes into mowiai.jar"> ��� <jar jarfile="${jarfile}" basedir="${classes}" /> � </target> � <target name="clean" ��������� description="Deletes Java classes and jar file"> ��� <delete dir="${classes}" quiet="true" /> ��� <delete file="${jarfile}" quiet="true" /> � </target> </project> ========== fork="false" =========== P:\com_lgc\acme>%DS_HOME%\tools\ant\bin\ant -emacs register Buildfile: build.xml init: classes: register: Scanning searchpath for components to register... Found 5 components (1406 ms) BUILD FAILED 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 init: classes: register: Scanning searchpath for components to register... Found 5 components (1047 ms) REGISTER SERVICE name� TetMeshAppletAdapter RenderAction REGISTER SERVICE class com.lgc.mowi.viz.acme.TetMeshAppletAdapter BUILD SUCCESSFUL Total time: 19 seconds P:\com_lgc\acme> ========== fork="false" -debug =========== [snip] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
