2013-07-13 51 views
0

我已經JAVA_HOME和ANT_HOME都設置:構建失敗的apache-tomcat的-7.0.42-SRC的build.xml

[email protected]:~/apache-tomcat-7.0.42-src$ echo $ANT_HOME 
/home/damechen/tmp/damechen/apache-ant-1.9.1 
[email protected]:~/apache-tomcat-7.0.42-src$ echo $JAVA_HOME 
/usr/lib/jvm/jdk1.7.0.25 
[email protected]:~/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 
[email protected]:~/apache-tomcat-7.0.42-src$ 

任何人都可以請給我個忙嗎?非常感謝!

回答

1

正如例外說的那樣。在嘗試通過/usr/share/java/中的名稱tomcat-native-1.1.27創建目錄時,內置失敗。

請給予適當的權利。

+0

感謝Junaid。這是在build屬性文件中沒有正確設置目錄的原因。我改變了它,並且解決了這個問題的失敗問題:) – damingzi

1

你需要閱讀的Apache Tomcat構建指令:構建

  1. 構建是通過創建一個$ {控制

    (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 
    
  2. 配置base.path屬性{} tomcat.source文件/build.properties中。

    base.path屬性指定下載構建所需的Tomcat依賴關係 的位置。建議將這個 目錄放在源代碼樹之外,這樣就不會浪費您的時間重新下載這些庫。

    • 警告:base.path屬性的默認值使構建腳本 下載到構建Tomcat到/ usr/share/java目錄 目錄所需的庫。在典型的Linux或MacOX系統上,普通用戶不會有 訪問權限寫入此目錄。即使您確實有權訪問 該目錄,但您可能不適合在此處編寫該目錄。

注意最後警告....這是你的問題的根本原因。

分析

build file被調用 「下載-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> 

    .. 
    .. 

在你的構建。屬性文件已設置的公地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} 
+0

謝謝馬克!請參閱下面的答案:) – damingzi

+0

@damingzi您提供給自己的問題的答案實際上是一個新問題。我想這就是爲什麼它被主持人刪除。 –