ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15018] - taskdef + getResourceAsStream broken
Date Tue, 03 Dec 2002 20:24:14 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15018>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15018

taskdef + getResourceAsStream broken





------- Additional Comments From elkner@linofee.org  2002-12-03 20:24 -------
Well, the mentioned problem (Bug 6606) is unrelated: 
1) fop.jar is not in the system classpath.
2) Even if fop.jar would be in the system classpath, the sys classloader would
   be able to find the resource, since it is in the same archive and thus in the 
   sys classpath as well.

The point is, that ant does not set the ContextClassLoader to the AntClassLoader
and thus any request from the application itself to a Resource needs to be 
satisfied by the sys classLoader, which does not know anything about the 
"extended" classpath. The request can not be satisfied since the request
is never delegated to the AntClassLoader since the AntClassLoader is simply
not in the chain ...

Thus, IMHO, if ant creates a new task (thread), it should set the threads
ContextClassLoader to the AntClassLoader, which will find anything in 
the "extended" classpath, if its delegates (i.e. normally the sys classLoader)
canīt find it.


As a workaround I did:
  Thread.currentThread()
    .setContextClassLoader(FOPTaskStarter.class.getClassLoader());

FOPTaskStarter.class.getClassLoader() results in an AntClassLoader.

Doing that everything works as expected. 
And since ant loads the Task class, it is actually the clean way
and the way it should be done.

--
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