Tomcat ant任务执行错误



我在运行tomcat ant任务时遇到问题。我发现了几个类似的案例,但没有一个有帮助:

ant安装以部署Tomcat Web应用程序失败,出现权限问题

为什么Ant在部署时返回403?

Ant Tomcat 7重新加载文件NotFoundException

版本:

  • 操作系统: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:Usersusernameantbuild.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:Usersusernameantbuild.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:服务器返回HTTP响应代码:403…

该错误是否可能是由路径中编码的(%2F)斜线符号引起的?

非常感谢)

看起来所有设置都正常:

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

现在一切都正常了。

我很遗憾没有早点检查。

相关内容

  • 没有找到相关文章

最新更新