ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <DDevie...@lgc.com>
Subject RE: custom taskdef requires Ant classloading of external JARs
Date Tue, 22 Feb 2005 20:41:09 GMT
So to summarize, if you put your 3 jars on the Application ClassLoader
or the Extension ClassLoader, it works fine, but when the jars on in the
Ant ClassLoader, it doesn't.

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

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.

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 [mailto:JLangr@ezenia.com]
> Sent: Tuesday, February 22, 2005 12:57 PM
> To: 'user@ant.apache.org'
> Subject: custom taskdef requires Ant classloading of external JARs
> 
> Greetings,
> 
> I'm using Ant 1.6.1 under WinXP SP2.
> 
> I wrote a custom task, deployToCache, that reads from a URL; the URL
can
> sometimes be https. Here's the taskdef definition:
> 
>    <taskdef name="deployToCache"
> classname="infoworkspace.build.DeployToCache">
>        <classpath>
>           <pathelement location="./DeployUtils.jar" />
>        </classpath>
>    </taskdef>
> 
> 
> The custom task requires jnet.jar, jsse.jar, and jcert.jar. The
relevant
> code:
> 
>       System.setProperty("java.protocol.handler.pkgs",
> "com.sun.net.ssl.internal.www.protocol");
>       Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider());
> 
> Access to the secure URL works fine when the code is run standalone,
but
> when it's run as the Ant task, the provider isn't getting picked up.
I'm
> aware that the custom task runs in Ant's Java process. If I change
ant.bat
> 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%"
> org.apache.tools.ant.launch.Launcher %ANT_ARGS% -lib "%CLASSPATH%"
> %ANT_CMD_LINE_ARGS%
> 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
adding
> the
> JARs as pathelements:
> 
>    <taskdef name="deployToCache"
> classname="infoworkspace.build.DeployToCache">
>        <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
classloader
> directory (jre/lib/ext), but I don't necessarily want to do that.
> 
> Thanks for any help.
> 
> Regards,
> Jeff
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message