ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ara Abrahamian" <ara_...@yahoo.com>
Subject RE: Problem with ANT classloader?
Date Fri, 17 May 2002 20:08:02 GMT
We also had lots of problems with AntClassLoader in xdoclet. It's a
super-messy piece of code. See below some of the thoughts (not mine,
anyway) in this regard:

<problem-with-getProtectionDomain/etc-1.1/1.2>
The correct approach is for ant's classloader to extend
SecureClassLoader, and specify the correct defineClass method with the
right CodeSource.
I'm surprised and disgusted by the ugliness of ant's classloader. Using
reflection to keep 1.1 compatibility is particularly ugly, and it also
means that now it's that much harder to fix the codesource bug given the
way the whole protectiondomain stuff is currently done in
AntClassLoader. A more sensible approach would be to define two
classloaders, a 1.1 and a 1.2 one, with a helper delegate class to hold
common functionality.
</problem-with-getProtectionDomain/etc-1.1/1.2>

<problem-with-xml-validation>
We had to do the same thing as XmlValidateTask to work with xml parser
(class.forName/hardcoding). It throws LinkageException if you do normal
jaxp style coding. It somehow became super-slow when classes where
loaded with AntClassLoader's intervention instead of system class
loader.
</problem-with-xml-validation>

I hope you find some time to refactor it a bit :-)

Ara.

> -----Original Message-----
> From: Dominique Devienne [mailto:DDevienne@lgc.com]
> Sent: Saturday, May 18, 2002 12:06 AM
> To: Ant Developers List
> Subject: FW: Problem with ANT classloader?
> 
> Don't any of the ANT experts out there have any clue what's going on
here?
> --DD
> 
> -----Original Message-----
> From: Dominique Devienne [mailto:DDevienne@lgc.com]
> 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:ianatkin@blueyonder.co.uk]
> 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:DDevienne@lgc.com]
> Sent: Friday, May 17, 2002 11:09 AM
> To: 'ant-user@jakarta.apache.org'
> 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:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:ant-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message