2012-02-09 55 views
3

我試圖從Ant開始/停止tomcat。這裏是停止我的XML文件的相關部分:從Ant開始/停止Tomcat - NoClassDefFoundError

<target name="stop" depends="readProperties" > 
    <exec executable="/home/local/WorkEnvironment/apache-tomcat-7.0.14/bin/"> 
     <arg value="shutdown.sh"/> 
    </exec> 
</target> 

這給了以下異常:

/home/local/workspace/Eclipse/Main/tomcat.xml:26: Execute failed: java.io.IOException: java.io.IOException: Permission denied 
    at java.lang.PosixProcess.<init>(libgcj.so.11) 
    at java.lang.Runtime.execInternal(libgcj.so.11) 
    at java.lang.Runtime.exec(libgcj.so.11) 
    at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:862) 
    at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481) 
    at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495) 
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:631) 
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:672) 
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:498) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) 
    at java.lang.reflect.Method.invoke(libgcj.so.11) 
    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:390) 
    at org.apache.tools.ant.Target.performTasks(Target.java:411) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) 
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368) 
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251) 
    at org.apache.tools.ant.Main.runBuild(Main.java:809) 
    at org.apache.tools.ant.Main.startAnt(Main.java:217) 
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) 
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) 
Caused by: java.io.IOException: Permission denied 
    at java.lang.PosixProcess.nativeSpawn(libgcj.so.11) 
    at java.lang.PosixProcess.spawn(libgcj.so.11) 
    at java.lang.PosixProcess$ProcessManager.run(libgcj.so.11) 

看到這一幕,我試過如下:

<target name="stop" depends="readProperties" > 
    <echo message="${tomcat.path.home}"/> 

    <java jar="${tomcat.path.home}/bin/bootstrap.jar" fork="true"> 
      <jvmarg value="-Dcatalina.home=${tomcat.path.home}"/> 

      <arg line="stop"></arg> 
    </java> 
</target> 

這告訴我即:

stop: 
    [echo] /home/local/WorkEnvironment/apache-tomcat-7.0.14 
    [java] Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.juli.logging.LogFactory 
    [java] at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:60) 
    [java] at java.lang.Class.initializeClass(libgcj.so.11) 
    [java] Java Result: 1 

我檢查了tomcat-juli.jar及其在tomcat_home/bin中的存在以及tomcat_home/lib中的存在。它也有螞蟻說缺失的班。出了什麼問題?我看到有時Manifest.MF文件可能會誤導,但是,我無法弄清楚這個文件究竟有什麼可能是錯誤的:(。

回答

3

不應該執行包括「shutdown.sh」? ARG,但可執行文件路徑的一部分)

喜歡的東西:

<target name="stop" depends="readProperties" > 
    <exec executable="/home/local/WorkEnvironment/apache-tomcat-7.0.14/bin/shutdown.sh"> 
    </exec> 
</target> 
+1

嘿,感謝這工作,我周圍的Googling,我看見它被作爲參數傳遞我的壞謝謝!。 ! – crazyaboutliv 2012-02-09 16:02:06