ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rainer Noack" <rai...@noacks.net>
Subject RE: custom taskdef requires Ant classloading of external JARs
Date Tue, 22 Feb 2005 23:12:11 GMT
Hi Jeff,

It seems, something needs to be available in the SystemClassloader.
I'm not familiar with ssl in special but typically security sensitive
service-activation is either done explicitely by a System property or (by
default) from the first specially named resource in a META-INF directory
that was found in the SystemClassloader.

If you run ant.bat, Ant's SystemClassloader is not identically with the
environmental CLASSPATH or the stuff you find in the java.classpath System
property.
This - and the stuff from Ant's lib dir - is only available from the
AntClassloader.

If there is the possibility for setting an explicite property and you know
it's name and correct value, 
you can set it by specifying -Dname=value as Environmentvariable ANT_OPTS.
Otherwise, there is unfortunately no other solution than those that are
working for you.
(IMHO, the most elegant way is using the java extension library.)

Regards

Rainer


> -----Original Message-----
> From: Jeff Langr [mailto:JLangr@ezenia.com] 
> Sent: Tuesday, February 22, 2005 7: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;%SECURE
> JARS%\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