ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Langr <>
Subject RE: custom taskdef requires Ant classloading of external JARs
Date Tue, 22 Feb 2005 20:53:37 GMT
Thanks Dominique for the reply.

> So to summarize, if you put your 3 jars on the Application ClassLoader or
> Extension ClassLoader, it works fine, but when the jars on in the Ant
> it doesn't.


> What do you mean that the provider is not getting picked up? Does the new
> call fail with a ClassNotFoundException? Sounds unlikely.

The result is a MalformedURLException, indicating that https is an unknown
protocol, when you try to construct a URL object.

> I personally thoughts java.protocol.handler.pkgs had to be set very early,
usually on 
> the java command line, but this does not seem to prevent your code from
working in 
> standalone mode, so that's probably not it.

Correct. Everything works fine standalone (or under the other conditions
described above).

My uneducated guess is that Ant's process itself already has loaded the
Security class and as such, any class it in turn tries to load is implicitly
loaded by Ant's appclassloader (or the extensions classloader). Or something
like that. I haven't looked at the code yet, that'd be the next step; it
wouldn't be too tough to prove one way or another what's going on. But I
figured someone else has to have come across this issue (and maybe using the
extclassloader is the best solution for now).


-----Original Message-----
From: Dominique Devienne [] 
Sent: Tuesday, February 22, 2005 1:41 PM
To: Ant Users List
Subject: RE: custom taskdef requires Ant classloading of external JARs


It's probably unrelated, but the Launcher does indeed set itself as the
Context ClassLoader, as it's supposed to.

That's a tough one. Since it involves security, there's probably something
else at play here!? --DD

> -----Original Message-----
> From: Jeff Langr []
> Sent: Tuesday, February 22, 2005 12:57 PM
> I'm using Ant 1.6.1 under WinXP SP2.
> I wrote a custom task, deployToCache, that reads from a URL; the URL
> sometimes be https. Here's the taskdef definition:
>    <taskdef name="deployToCache"
> classname="">
>        <classpath>
>           <pathelement location="./DeployUtils.jar" />
>        </classpath>
>    </taskdef>
> The custom task requires jnet.jar, jsse.jar, and jcert.jar. The
> code:
>       System.setProperty("java.protocol.handler.pkgs",
> "");
>       Security.addProvider(new;
> Access to the secure URL works fine when the code is run standalone,
> when it's run as the Ant task, the provider isn't getting picked up.
> aware that the custom task runs in Ant's Java process. If I change
> and alter Ant's classpath in the batch file, things work fine:
> :runAntWithClasspath
> setlocal
> set SECUREJARS=c:\IWS251\CMBuild\ClassFiles\2512Classes
> "%_JAVACMD%" %ANT_OPTS% -classpath
> "%ANT_HOME%\lib\ant-
> launcher.jar;%SECUREJARS%\jsse.jar;%SECUREJARS%\jnet.jar
> ;%SECUREJARS%\jcert.jar" "-Dant.home=%ANT_HOME%"
> endlocal
> goto end
> If I put the three jars (jnet, jsse, jcert) in Ant's lib directory, it 
> does not work.
> I tried also enhancing the <classpath> portion of the taskdef and
> the
> JARs as pathelements:
>    <taskdef name="deployToCache"
> classname="">
>        <classpath>
>           <pathelement location="./DeployUtils.jar" />
>           <pathelement location="./jsse.jar" />
>           <pathelement location="./jcert.jar" />
>           <pathelement location="./jnet.jar" />
>        </classpath>
>    </taskdef>
> That didn't work.
> I looked at the Ant FAQ and didn't see anything that would help. The 
> closest entry seemed to be "<style> or <junit> ignores my 
> <classpath>."
> I'd rather not require changes to ant.bat. I also tried setting the 
> CLASSPATH prior to executing ant.bat. Unfortunately this only sets the
> lib
> parameter on the Ant Java app command line; same problem.
> One thing that does work is moving the three jars to the ext
> directory (jre/lib/ext), but I don't necessarily want to do that.

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

View raw message