Fixing broken JPackage Ant rpm for use with 3rd party JARs such as Ivy

I was building a Hadoop stack in my lab recently, which requires installing quite a bit of software. I try to use RPM’s when I can, especially if they are part of the distribution I am using. I am currently using CentOS 6.3.

I installed ant using yum. I next needed to install Apache Ivy, and did so from the tar ball at Apache.

Apache Ivy is pretty basic to install, essentially its just a JAR file you need to put into ANT_HOME. The installation instructions are explained here.

I had JAVA_HOME and ANT_HOME set appropriately as well.  The error you will get in running Ivy’s basic hello-ivy test is like so:

[root@hadoop01 hello-ivy]# ant
Buildfile: build.xml
/usr/local/apache-ivy-2.3.0-rc1/src/example/hello-ivy/build.xml:38: Problem: failed to create task or type antlib:org.apache.ivy.ant:retrieve
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -a directory added on the command line with the -lib argument
Total time: 0 seconds
Now apparently people have been getting this problem as far back as 2008!  I found this bug which gave some insight as to what is going on:

ASF Bugzilla – Bug 44849

The solution I implemented was to edit the ant.conf file, which looks like this:

[root@hadoop01 hello-ivy]# cat /etc/ant.conf
# ant.conf (Ant 1.7.x)
# JPackage Project <>
# Validate –noconfig setting in case being invoked
# from pre Ant 1.6.x environment
if [ -z “$no_config” ] ; then
# Setup ant configuration
if $no_config ; then
  # Disable RPM layout
  # Use RPM layout
  # ANT_HOME for rpm layout
and I changed the line with rpm_mode=true to rpm_mode=false.  Ivy then works fine.  I am sure this effects many other 3rd party JAR files being used with Ant as well.  It’s very frustrating to have to do this, hopefully someone at JPackage makes corrections to Ant.  Here is the build of hello-ivy after the change to /etc/ant.conf:
[root@hadoop01 hello-ivy]# ant
Buildfile: build.xml
[ivy:retrieve] :: Apache Ivy 2.3.0-rc1 – 20120416000235 :: ::
[ivy:retrieve] :: loading settings :: url = jar:file:/usr/share/ant/lib/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@localhost
[ivy:retrieve]  confs: [default]
[ivy:retrieve]  found commons-lang#commons-lang;2.0 in public
[ivy:retrieve]  found commons-cli#commons-cli;1.0 in public
[ivy:retrieve]  found commons-logging#commons-logging;1.0 in public
[ivy:retrieve] :: resolution report :: resolve 177ms :: artifacts dl 11ms
[ivy:retrieve]  :: evicted modules:
[ivy:retrieve]  commons-lang#commons-lang;1.0 by [commons-lang#commons-lang;2.0] in [default]
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        |      default     |   4   |   0   |   0   |   1   ||   7   |   0   |
[ivy:retrieve] :: retrieving :: org.apache#hello-ivy
[ivy:retrieve]  confs: [default]
[ivy:retrieve]  0 artifacts copied, 7 already retrieved (0kB/6ms)
     [java] standard message : hello ivy !
     [java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !
Total time: 0 seconds

Hopefully this helps others having the same problem.

This entry was posted in Software Engineering. Bookmark the permalink.

1 Response to Fixing broken JPackage Ant rpm for use with 3rd party JARs such as Ivy

Leave a Reply