我在运行tomcat ant任务时遇到问题。 我找到了几个类似的案例,但没有一个帮助:
ant install to deploy Tomcat webapp failing with permission problem
Why is Ant returning a 403 on deploy?
Ant Tomcat 7 Reload FileNotFoundException
版本:
我的tomcat-users.xml:
<tomcat-users><role rolename="manager-script"/>
<user username="script" password="script" roles="manager-script"/>
<role rolename="manager-gui"/>
<user username="manager" password="manager!" roles="manager-gui"/>
</tomcat-users>
Ant脚本的一部分:
<property name="app.name" value="london"/>
<property name="manager.url" value="http://localhost:8081/manager/text"/>
<property name="manager.user" value="script"/>
<property name="manager.password" value="script"/>
<property name="update.filename" value="update.war"/>
<taskdef name="tomcatStart" classname="org.apache.catalina.ant.StartTask"/>
<taskdef name="tomcatStop" classname="org.apache.catalina.ant.StopTask"/>
<taskdef name="tomcatDeploy" classname="org.apache.catalina.ant.DeployTask"/>
<target name="main">
<tstamp/>
<tomcatStop
url="${manager.url}"
username="${manager.user}"
password="${manager.password}"
path="/${app.name}"
/>
<tomcatDeploy
url="${manager.url}"
username="${manager.user}"
password="${manager.password}"
path="/${app.name}"
war="file:${update.filename}"
/>
</target>
控制台输出(StopTask):
BUILD FAILED
C:\Users\username\ant\build.xml:34: java.io.FileNotFoundException:
http://localhost:8081/manager/text/stop?path=%2Flondon
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1434)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:228)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:149)
at org.apache.catalina.ant.StopTask.execute(StopTask.java:73)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
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:811)
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)
Total time: 0 seconds
控制台输出(DeployTask):
BUILD FAILED
C:\Users\username\ant\build.xml:35: java.io.IOException: Server returned HTTP response code: 403 f
or URL: http://localhost:8081/manager/text/deploy?path=%2Flondon
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:228)
at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:211)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
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:811)
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)
Total time: 0 seconds
奇怪的是,我让它工作了几次,但现在它再也没有用了。
另一个奇怪的事情是,StartTask和StopTask生成FileNotFoundException,但是DeployTask生成java.io.IOException:Server返回HTTP响应代码:403 ...
路径中的编码(%2F)斜杠符号可能导致错误吗?
非常感谢)
答案 0 :(得分:1)
看起来所有设置都可以:
现在一切正常。
我不想早点检查它。