You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Karr, David" <da...@wamu.net> on 2008/03/27 17:33:41 UTC

Defined task fails to find base class of task

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 class it can't find it 

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="nbuild.properties"/>
 
   <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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Defined task fails to find base class of task

Posted by "Karr, David" <da...@wamu.net>.
I think I have to do that because one of the classes compiled by the
compile step is the class referenced in the taskdef.  What I found was
that if I defined the taskdef at the "top level", not inside a target,
no matter where it was sequentially in the build script, it would fail
on the taskdef immediately because it couldn't find the class, even
before it executed the compile step.

> -----Original Message-----
> From: Scot P. Floess [mailto:floess@mindspring.com] 
> Sent: Thursday, March 27, 2008 11:15 AM
> To: Ant Users List
> Subject: Re: Defined task fails to find base class of task
> 
> Yeah, I posted a question about this recently.  I got 
> side-tracked and never fully pursued the issue...  I don't 
> think it works - I saw the same behavior as you...
> 
> Curious, why are you structuring in this fashion?  Meaning 
> performing the taskdef in a target?  Not a criticism - just 
> curious as to why.  I had a real reason in doing so myself :)
> 
> Karr, David wrote:
> > 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 class it can't find it
> >
> > 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="nbuild.properties"/>
> >  
> >    <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: user-unsubscribe@ant.apache.org For 
> additional 
> > commands, e-mail: user-help@ant.apache.org
> >
> >
> >   
> 
> --
> Scot P. Floess
> 27 Lake Royale
> Louisburg, NC  27549
> 
> 252-478-8087 (Home)
> 919-754-4592 (Work)
> 
> Chief Architect JPlate   http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM  http://sourceforge.net/projects/javapim
> 
> Architect Keros          http://sourceforge.net/projects/keros
> 
> 
> ---------------------------------------------------------------------
> 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


Re: Defined task fails to find base class of task

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Yeah, I posted a question about this recently.  I got side-tracked and 
never fully pursued the issue...  I don't think it works - I saw the 
same behavior as you...

Curious, why are you structuring in this fashion?  Meaning performing 
the taskdef in a target?  Not a criticism - just curious as to why.  I 
had a real reason in doing so myself :)

Karr, David wrote:
> 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 class it can't find it 
>
> 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="nbuild.properties"/>
>  
>    <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: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>   

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros


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