gpt4 book ai didi

java - Tomcat ant任务执行错误

转载 作者:行者123 更新时间:2023-11-28 22:22:37 25 4
gpt4 key购买 nike

我在运行 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

版本:

  • 操作系统:Windows 7 x64 Professional
  • Java 版本:1.6.0_25
  • Ant 版本:1.8.3
  • Tomcat 版本:7.0.011

我的 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 returned HTTP response code: 403...

是否可能是路径中编码的 (%2F) 斜杠符号导致的错误?

非常感谢)

最佳答案

看起来所有设置都正常:

  • 我删除了 Tomcat 文件夹
  • 解压新副本
  • 应用设置

现在一切正常。

我很遗憾没有早点那样检查它。

关于java - Tomcat ant任务执行错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9685893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com