Reputation: 716
I have both JAVA_HOME and ANT_HOME set:
damechen@ubuntu:~/apache-tomcat-7.0.42-src$ echo $ANT_HOME
/home/damechen/tmp/damechen/apache-ant-1.9.1
damechen@ubuntu:~/apache-tomcat-7.0.42-src$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.7.0.25
damechen@ubuntu:~/apache-tomcat-7.0.42-src$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
I was trying to use ant to build tomcat, but it failed for some reasons related to build.xml.
BUILD FAILED
/home/damechen/apache-tomcat-7.0.42-src/build.xml:2396: The following error occurred while executing this line:
/home/damechen/apache-tomcat-7.0.42-src/build.xml:2625: Directory /usr/share/java/tomcat-native-1.1.27 creation was not successful for an unknown reason
at org.apache.tools.ant.taskdefs.Mkdir.execute(Mkdir.java:70)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:440)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: 0 seconds
damechen@ubuntu:~/apache-tomcat-7.0.42-src$
Anyone can kindly give me a hand? Thanks a lot!
Upvotes: 0
Views: 2591
Reputation: 77971
You need to read the build instructions for Apache tomcat:
(3.2) Building
The build is controlled by creating a ${tomcat.source}/build.properties file.
It is recommended to always create the file, because of unfortunate default value of base.path property. You may start with the following content for the file:
# ----- Default Base Path for Dependent Packages ----- # Replace this path with the directory path where dependencies binaries # should be downloaded base.path=/home/me/some-place-to-download-to
Configure base.path property by adding it to the ${tomcat.source}/build.properties file.
The base.path property specifies the place where Tomcat dependencies required by the build are downloaded. It is recommended to place this directory outside of the source tree, so that you do not waste your time re-downloading the libraries.
- WARNING: The default value of base.path property makes the build script to download libraries required to build Tomcat to the /usr/share/java directory. On a typical Linux or MacOX system an ordinary user will not have access to write to this directory. Even if you do have access to that directory, it is likely not appropriate for you to write there.
Note the warning at the end.... This is the root cause of your issue.
The build file is calling the "download-2" target when it fails:
<target name="extras-commons-logging-prepare"
depends="extras-prepare"
description="Prepare to build web services extras package">
<antcall target="downloadfile-2">
<param name="sourcefile.1" value="${commons-logging-src.loc.1}"/>
<param name="sourcefile.2" value="${commons-logging-src.loc.2}"/>
<param name="destfile" value="${commons-logging-src.tar.gz}"/>
<param name="destdir" value="${commons-logging.home}"/>
</antcall>
..
..
In your build.properties file you have set the value of the commons-logging.home property to a directory path for which you do not have permissions to create a directory namely:
/usr/share/java/...
Digging further I see that default properties file sets this path as follows:
# ----- Default Base Path for Dependent Packages -----
# Please note this path must be absolute, not relative,
# as it is referenced with different working directory
# contexts by the various build scripts.
base.path=/usr/share/java
#base.path=C:/path/to/the/repository
#base.path=/usr/local
..
..
commons-logging.version=1.1.1
commons-logging.home=${base.path}/commons-logging-${commons-logging.version}
Upvotes: 1
Reputation: 7871
As the exceptions says. The built failed while it was trying to create a directory by the name tomcat-native-1.1.27
in /usr/share/java/
.
Please give proper rights.
Upvotes: 1