ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Arnold" <>
Subject Problem with using jar files for user defined taskdefs
Date Wed, 16 Oct 2002 23:53:03 GMT
I had this problem with several jar files now:

I define my own tasks using the <taskdef> tag. The class file for this Task object is
in mySpecial.jar, it uses junit and the junit
optional ant tasks. I specify all the required jar files within my taskdef:

    <taskdef name="myTask" classname="com.mine.myOwnSpecialTask">
        <pathelement location="J:/lib/mySpecial.jar"/>
        <pathelement location="J:/lib/junit.jar"/>
        <pathelement location="J:/lib/optional.jar"/>

When I try to execute my task, ant is giving me a ClassNotFoundException saying that com.mine.myOwnSpecialTask
does not exist.
The jar file is fine however.

Copying mySpecial.jar into %ANT_HOME%/lib did not help either. After some hours I finally
found that copying all the 3 jar files
(optional.jar was already there anyway, but junit.jar was not there yet) into %ANT_HOME%/lib
as well finally made it work.

So 2 questions:
1. Why do I have to copy the jars into %ANT_HOME%/lib if I already specify them in the classpath
tag for the taskdef?
2. Why does ant tell me it can not find myOwnSpecialTask in mySpecial.jar if the problem is
really the junit.jar and some of the
classes in there which I inherit myOwnSpecialTask from?

I had a similar problem trying to use another user-defined non-standard ant task that was
using xalan.jar. It told me that it could
not find some of the classes in that jar file even though the location of the jar file in
the classpath tag was specified correctly.
Only after I moved the xalan.jar into the %ANT_HOME%/lib did it finally work.

I am using Sun's JDK1.3.1 and ant1.5.1 (downloaded today, 10/16/2002) on a Windows2000 workstation.
However, it looks like I am
having the same problem on Linux systems (same ant & JDK) as well. It is definitely not
a permission / typo in the filename / etc.
stupid problem...

Is this problem a bug in ant or is the classpath tag within the taskdef not meant to be used
for what I think it is?



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

View raw message