Bug 23541 - Enhance error messages of taskdef to say what really is not found...
Summary: Enhance error messages of taskdef to say what really is not found...
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.5.3
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL: http://nagoya.apache.org/bugzilla/sho...
Depends on:
Blocks: 23741
  Show dependency tree
Reported: 2003-10-01 12:31 UTC by Ralf Hauser
Modified: 2008-02-22 12:18 UTC (History)
0 users

this patch to AntClassLoader.java may save many people a lot of worries! (219 bytes, patch)
2003-10-11 09:46 UTC, Ralf Hauser
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Hauser 2003-10-01 12:31:45 UTC
if the class is found but some import not, mention this specifically!!
Since I have the target also print the directory path and then verify it 
manually, I cannot imaging that the classes proper are not found...

The current error message is not all to helpful ...    :(

Somebody sent me two *.java files I can compile in my eclipse, but ant fails to
recognize them as tasks even though the provider says he has it running with the
same build.xml snippet:

<<It's not clear to me why your example isn't working, though, it seems
basically correct.


>     <property name="dumpFields_dir"
>        location="${basedir}/WEB-INF/classes/net/sf/cglib/transform"/>
>     <property name="myProjClasses_dir"
>          location="${build.dir}/com/myDom/myProj"/>
> <path id="dumpFileClasspath.path">
>    <pathelement location="${dumpFields_dir}"/>
> </path>
> <target name="dumpfields"><!-- depends="compile"-->
>   <echo message="${dumpFields_dir}" />
>     <taskdef name="dumpfields" classpathref="dumpFileClasspath.path"
>        classname="net.sf.cglib.transform.DumpFieldsTask" />
>     <dumpfields outputFile="${javaConstFile}">
>        <fileset dir="${myProjClasses_dir}/business">
>             <include name="**/*.class"/>
>        </fileset>
>     </dumpfields>
> </target>
> I am getting:
> c:\data\\eclipse\workspace\myProj>ant dumpfields
> Buildfile: build.xml
> dumpfields:
>      [echo]
> C:\data\eclipse\workspace\myProj\WEB-INF\classes\net\sf\cglib\transform
> file:c:/data/eclipse/workspace/myProj/build.xml:65: taskdef class 
> net.sf.cglib.transform.DumpFieldsTask cannot be found
> Total time: 3 seconds
> c:\data\eclipse\workspace\myProj>dir
> C:\data\eclipse\workspace\privaLope\WEB-INF\classes\net\sf\cglib\tra
> nsform
>  Volume Serial Number is 1A25-17E1
>  Directory of
> C:\data\eclipse\workspace\myProj\WEB-INF\classes\net\sf\cglib\transform
> 29.09.2003  19:50       <DIR>          .
> 29.09.2003  19:50       <DIR>          ..
> 29.09.2003  19:53                1'726 DumpFieldsTask.class
> 29.09.2003  19:53                2'042 DumpFieldsTask$1.class
> 29.09.2003  19:53                2'569 AbstractProcessTask.class
>                3 File(s)          6'337 bytes>>
Comment 1 Ralf Hauser 2003-10-11 09:46:23 UTC
Created attachment 8534 [details]
this patch to AntClassLoader.java may save many people a lot of worries!
Comment 2 Ralf Hauser 2003-10-11 10:22:37 UTC
similar problems with inner classes are reported in
Comment 3 Ralf Hauser 2003-10-13 15:03:39 UTC
o.k. Thanks to Stefan, I figured that my class-path went too close to the real file.

Therefore, my suggestion alter the current error message as follows to prevent
"classpath-conventions-ignorants" like myself from endless trials:

taskdef class net.sf.cglib.transform.DumpFieldsTask cannot be found>>

1)<<Could not find Class net.sf.cglib.transform.DumpFieldsTask.class in
C:\data\MyProj\WEB-INF\classes\net\sf\cglib\transform (the "." in the classname
will converted into path delimiters as per your platform.)"

2) debug case:
Current: <<Finding class net.sf.cglib.transform.DumpFieldsTask>>

Suggestion: as per my
<<C:\data\MyProj\WEB-INF\classes\net\sf\cglib\transform (the "." in the
classname will converted into path delimiters as per your platform.

- did you specify a path that is too deep?
- did you put the directory of a jar file into the path instead of the jar itself?
see also http://ant.apache.org/manual/using.html#path>>

Perhaps, it would also be useful to:
3) enhance http://ant.apache.org/manual/using.html#path with a reference to the
official java classpath conventions
4) or mention the important parts of the classpath convention there
Comment 4 Ralf Hauser 2003-10-14 03:44:22 UTC
another safeguard would be to warn users who do not have dots "." in their class
name that they most likely are forgetting that the "classpath" is basically a
"classROOTpath" and need not to go up to the very file.
==> can the fully qualified classname be made mandatory?
Comment 5 Ralf Hauser 2007-11-28 07:53:20 UTC
see also Bug 43982