Bug 23541

Summary: Enhance error messages of taskdef to say what really is not found...
Product: Ant Reporter: Ralf Hauser <hauser>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: ASSIGNED ---    
Severity: enhancement    
Priority: P3    
Version: 1.5.3   
Target Milestone: ---   
Hardware: PC   
OS: All   
URL: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16970
Bug Depends on:    
Bug Blocks: 23741    
Attachments: this patch to AntClassLoader.java may save many people a lot of worries!

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 ...    :(

Background:
===========
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.

Chris


> 
>     <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
> 
> BUILD FAILED
> 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
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23741
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:

Current:
<<C:\data\MyDocRalf\bin\Java\jars\eclipse\workspace\privaLope\build.xml:76:
taskdef class net.sf.cglib.transform.DumpFieldsTask cannot be found>>

Suggestions:
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
http://nagoya.apache.org/bugzilla/showattachment.cgi?attach_id=8534
<<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