You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Daniel Hoppe <ho...@sitewaerts.de> on 2001/09/10 22:29:04 UTC

Problem with Style task and classloader

Hi,

I'm stuck with a problem in the style task. I think I might have a rough
idea what's wrong and would like to get some input how I could fix this.

I'm trying to use Saxon as processor for the style task with the following
code:

		<style 	
	
in="deployments/${deployment}/components/deployment.xml" 
			out="build/thisconfig/makecscomponents.xml" 
	
style="build/thisconfig/generatecomponentmakefile.xsl"
			processor="trax"
			force="true">
			<classpath>
			      <pathelement location="lib/saxon.jar"/>
    			</classpath>
		</style>

What happens is that TraXLiaison is correctly called but then happily calls
Xalan. If I read the code correctly this is because although TraXLiaison is
loaded with the ant classloader and build.sysclasspath is set to ignore, the
call to isParentFirst in loadClass returns true - quite natural, it's in
optional.jar, where else could it come from - so the whole JAXP stuff
happening in TraxLiaison runs in the system classloader. The system
classloader loads classes according to the delegation model, therefore it
can never find a class specified in the nested classpath of the style task.
If I'm right so far the nested classpath of the style task seems a little
bit pointless.
I first thought of adding an attribute to specify the transformer explicitly
and put jaxp into the nested classpath element, but of course this does not
help as TraXLiaison will actually never look into this nested classpath.

I'd like to write a fix for this, but I'm not sure how this could be
accomplished within the current XXXLiaison model. A possible approach might
be to load the jaxp TransformerFactory from the nested classpath together
with the parser in the TraXLiaison implementation, but that would not fit
the XSLTLiaison interface.

I hope that my problem is somehow understandable and tt would be nice if
someone could give me some hints how I could work on from here.

Cheerios,

Daniel


<<<<<<<<<<<<<<<<<<<<<<<<<<<
sitewaerts GmbH
Hebelstraße 15
D-76133 Karlsruhe

Tel: +49 (721) 920 918 0
Fax: +49 (721) 920 918 29
http://www.sitewaerts.de
>>>>>>>>>>>>>>>>>>>>>>>>>>>



Re: Problem with Style task and classloader

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 10 Sep 2001, Daniel Hoppe <ho...@sitewaerts.de> wrote:

> If I read the code correctly this is because although TraXLiaison is
> loaded with the ant classloader and build.sysclasspath is set to
> ignore, the call to isParentFirst in loadClass returns true - quite
> natural, it's in optional.jar, where else could it come from - so
> the whole JAXP stuff happening in TraxLiaison runs in the system
> classloader.

Sounds right to the point.  

This is kind of a known problem with optional tasks that need external
jars and allow for a nested classpath element - <junit> has the same
problem if you want to include junit.jar in the tasks classpath
element instead of the system classpath for example.

What probably would work in your case: remove TraxLiaison from
optional.jar and include it in the classpath you specify for the task.

Stefan