Bug 35060 - ant 1.6.4 does not seem to use ~/.ant/lib anymore
Summary: ant 1.6.4 does not seem to use ~/.ant/lib anymore
Status: RESOLVED INVALID
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.6.4
Hardware: Other other
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-25 14:15 UTC by Kaj J. Niemi
Modified: 2008-04-18 15:54 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kaj J. Niemi 2005-05-25 14:16:14 UTC
Something changed in ant between version 1.6.2 and 1.6.4 which leads to the fact
that jar files placed in ~/.ant/lib are not being used by ant anymore. I looked
at Launcher.java which seems to have been rewritten w.r.t. finding the .ant/lib
directory but then stracing the ant process does show that the file gets at
least statted but it doesn't seem to be used.

% jar tvf ~/.ant/lib/ant-contrib-basen-bootstrap.jar
     0 Wed Jul 28 22:36:10 EEST 2004 META-INF/
   379 Wed Jul 28 22:36:08 EEST 2004 META-INF/MANIFEST.MF
     0 Wed Jul 28 21:39:48 EEST 2004 net/
     0 Wed Jul 28 21:39:48 EEST 2004 net/basen/
     0 Wed Jul 28 21:39:48 EEST 2004 net/basen/antcontrib/
     0 Wed Jul 28 22:36:08 EEST 2004 net/basen/antcontrib/bootstrap/
  4159 Wed Jul 28 22:36:08 EEST 2004
net/basen/antcontrib/bootstrap/BasenTaskdef.class
    58 Wed Jul 28 22:36:08 EEST 2004
net/basen/antcontrib/bootstrap/bootstrap.properties

% ant
Buildfile: build.xml
  [taskdef] Could not load definitions from resource
net/basen/antcontrib/bootstrap/bootstrap.properties. It could not be found.

BUILD FAILED
/usr/src/cvs-in/FortN/FortN/build.xml:35: Could not create task or type of type:
basentaskdef.

Ant could not find the task or a class this task relies upon.

This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
 - You have misspelt 'basentaskdef'.
   Fix: check your spelling.
 - The task needs an external JAR file to execute
     and this is not found at the right place in the classpath.
   Fix: check the documentation for dependencies.
   Fix: declare the task.
 - The task is an Ant optional task and the JAR file and/or libraries
     implementing the functionality were not found at the time you
     yourself built your installation of Ant from the Ant sources.
   Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
     task and make sure it contains more than merely a META-INF/MANIFEST.MF.
     If all it contains is the manifest, then rebuild Ant with the needed
     libraries present in ${ant.home}/lib/optional/ , or alternatively,
     download a pre-built release version from apache.org
 - The build file was written for a later version of Ant
   Fix: upgrade to at least the latest release version of Ant
 - The task is not an Ant core or optional task
     and needs to be declared using <taskdef>.
 - You are attempting to use a task defined using
    <presetdef> or <macrodef> but have spelt wrong or not
   defined it at the point of use

Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath

Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.

Total time: 0 seconds



Any thoughts?
Comment 1 Peter Reilly 2005-05-26 18:53:37 UTC
can you please give a small self contained example.
My testing with ant 1.6.4 does no show this problem
Comment 2 Kaj J. Niemi 2005-05-27 16:07:03 UTC
(In reply to comment #1)
> can you please give a small self contained example.
> My testing with ant 1.6.4 does no show this problem

After further investigation the problem seems to lie in the fact that I/we use
JPackage rpms for ant and the way the files are laid out there; ant.jar and
ant-launcher.jar are found in /usr/share/java/ while everything else is in
/usr/share/java/ant/. Things work really well if I move/copy ant.jar and
ant-launcher.jar to the /usr/share/java/ant/ subdirectory - this one directory
approach is also the one you guys have in your ant binary distribution.

Playing around with the ant shell script (sh -x ant, really) I noticed that
1.6.2 starts as follows:

/usr/lib/jvm/java/bin/java -classpath
/usr/share/java/ant.jar:/usr/share/java/ant-launcher.jar:/usr/share/java/jaxp_parser_impl.jar:/usr/share/java/xml-commons-apis.jar:/usr/lib/jvm/java/lib/tools.jar
-Dant.home=/usr/share/ant -Dant.library.dir=/usr/share/ant/lib
org.apache.tools.ant.launch.Launcher -cp ''

The above does not seem to work at all with 1.6.4 while the one below works fine:

/usr/lib/jvm/java/bin/java -classpath /usr/share/java/ant-launcher.jar
-Dant.home=/usr/share/ant -Dant.library.dir=/usr/share/ant/lib
org.apache.tools.ant.launch.Launcher -cp
/usr/share/java/ant.jar:/usr/share/java/jaxp_parser_impl.jar:/usr/share/java/xml-commons-apis.jar:/usr/share/java/junit.jar:/usr/share/java/ant/ant-junit.jar:/usr/lib/jvm/java/lib/tools.jar

The jvm version is 1.4.2_08.

My original report of jars in ~/.ant/lib not being used wasn't true, it just
looked that way since ant didn't start up.

Comment 3 Peter Reilly 2005-05-27 17:41:56 UTC
Jpackage has not released ant 1.6.3 or 1.6.4 yet. I do not
know if there is an issue with their packaging of ant 1.6.4,
but there has been no such bug reports (yet).
If you want to use ant 1.6.4, you will need to use the
release from apache - try using the ant -noconfig options.

I am marking this as invalid - please reopen if there
is an issue with jpackage and ant 1.6.4 - if there
is, there will of course need to be a fix.
Comment 4 Trevin Beattie 2008-04-18 15:54:27 UTC
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ClasspathUtils.java?r1=276313&r2=277160&diff_format=h

Why does ClasspathUtils.getUniqueClassLoaderForPath no longer set the new class loader's classpath to the system class path when no explicit path is provided?

I'm having this same problem with ivy.  I tried copying ant.jar and ant-launcher.jar to /usr/share/java/ant/ as Kaj suggested, but in my case I still got the error "Could not create task or type of type: antlib:org.apache.ivy.ant:retrieve."

I loaded up ant in Eclipse's debugger and tried to trace through it.  All of the jars in ~/.ant/lib/ are added to the java.class.path system property as well as the thread's context class loader, but when ant goes to load the resource "org/apache/ivy/ant/antlib.xml", it's not using that URLClassLoader; it's using a new AntClassLoader2 instead.