ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rainer Noack" <>
Subject AW: (resent) Defined task fails to find base class of task
Date Fri, 28 Mar 2008 22:40:34 GMT
Hi David,

Dealing with ant-builds that compile a task and then use it is a beast.
There a some pitfalls in ant (and java).
Some years ago I wrote two tasks to introspect and manipulate the
classloader hierarchy in ant. You can find them at

(AFAIK they are not longer proposed for an ant release.)

Use the <classloaderreport> task immediately before using your task to find
out more about your classpathproblems.

The most simple usage for your problem is to add all your required classes
and jars to the "Project-Classloader".

Hope that helps.

Rainer Noack

-----Urspr√ľngliche Nachricht-----
Von: Karr, David [] 
Gesendet: Freitag, 28. März 2008 19:04
An: Ant Users List
Betreff: RE: (resent) Defined task fails to find base class of task

So far, what I'm finding is that if my task class is in my "build"
directory, but it references a class in another jar, and neither of
those locations is in the global classpath, specifying a "classpath"
attribute or nested element to specify those locations just won't work.

I've tried numerous variations of the "classpath" attribute and element,
specifying both the "build" directory and the referenced jar.  If I
leave the "build" directory out if it, it fails to find the task class.
However, no variation results in it finding the indirectly referenced

I even tried assembling another jar file that contains both the
referenced jar file and my task class, and setting that as the
"classpath" attribute.  This also fails to find the referenced class.

The only temporary workaround that's working is to edit my Eclipse Ant
classpath entries, adding the indirectly referenced jar file.  When I do
that, running the task finds both the task class and the referenced
class and executes the task.

Is this some symptom of running Ant from Eclipse?

Why can't I get a working taskdef that specifies the indirectly
referenced jar to work?

> -----Original Message-----
> From: Karr, David 
> Sent: Thursday, March 27, 2008 9:37 AM
> To: Ant Users List
> Subject: (resent) Defined task fails to find base class of task
> (Sorry, I somehow sent this before it was done.)
> I have a simple build file that compiles some files and has a 
> taskdef for one of the compiled classes, which indirectly 
> references a class in one of the jars in the classpath.  I 
> have the taskdef inside the target which uses the task.  When 
> it executes the defined task, it fails to find the class from 
> that jar (NoClassDefFound).  I ran SysInternals FileMon while 
> the build is running to verify it's reading the jar file with 
> that base class.
> The actual exception I get is:
> 	java.lang.NoClassDefFoundError:
> org/apache/oro/text/perl/Perl5Util
> This is referenced from the P4Base class, the base class of 
> my taskdef class.
> What could I be doing wrong here?
> Here is my simple build file:
> -----------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <project name="WLA" default="default" basedir=".">
>     <description>Builds, tests, and runs the project 
> WLA.</description>
>    <property file=""/>
>    <target name="default"
> depends="compile,install-label-info,build-war">
>    </target>
>     <target name="compile">
>         <delete dir="${build.classes.dir}"/>
>         <mkdir dir="${build.classes.dir}"/>
>         <javac srcdir="${src.dir}" destdir="${build.classes.dir}"
> fork="true"
>                debug="true" verbose="false">
>             <include name="**/*.java"/>
>             <classpath path="${javac.classpath}"/>
>         </javac>
>     </target>
>     <target name="build-war">
>     </target>
>    <target name="install-label-info">
>       <taskdef name="p4NewestLabel"
> classname="com.wamu.ant.perforce.P4NewestLabel">
>           <classpath path="${build.classes.dir}:${javac.classpath}"/>
>       </taskdef>
>       <echo message="classpath[${javac.classpath}]"/>
>       <p4NewestLabel labelName="label" labelDesc="labelDesc"/>
>    </target>
> </project>
> -----------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: For 
> additional commands, e-mail:

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

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

View raw message