我同时设置了JAVA_HOME和ANT_HOME:
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)
我试图使用ant来构建tomcat,但由于与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$
任何人都可以帮我一臂之力?非常感谢!
答案 0 :(得分:1)
正如例外所说。在尝试使用tomcat-native-1.1.27
中的名称/usr/share/java/
创建目录时,构建失败。
请给予适当的权利。
答案 1 :(得分:1)
您需要阅读Apache tomcat的构建说明:
(3.2)建筑
通过创建$ {tomcat.source} /build.properties来控制构建 文件。
建议始终创建该文件,因为不幸 base.path属性的默认值。您可以从以下开始 文件的内容:
# ----- 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
- 醇>
通过将base.path属性添加到。来配置它 $ {tomcat.source} /build.properties文件。
base.path属性指定Tomcat依赖项的位置 下载了构建所需的内容。建议放置它 源树之外的目录,这样你就不会浪费你的 时间重新下载库。
- 警告:base.path属性的默认值是构建脚本 下载构建Tomcat所需的库到/ usr / share / java 目录。在典型的Linux或MacOX系统上,普通用户不会 有权写入此目录。即使你有权访问 那个目录,你可能不适合在那里写。
请注意最后的警告....这是您的问题的根本原因。
build file在失败时调用“download-2”目标:
<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>
..
..
在build.properties文件中,您已将 commons-logging.home 属性的值设置为您无权创建目录的目录路径,即:
/usr/share/java/...
进一步挖掘我看到default properties文件设置此路径如下:
# ----- 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}