为什么Eclipse在Ant Tomcat任务似乎成功时报告BUILD FAILED?

3

当使用Tomcat管理器命令运行Ant目标时,它们似乎是成功的,但会报告BUILD FAILED。

以下是我的build.xml文件中相关的部分:

<property name="path"     value="/MyApp"/>

<property name="manager-url" value="http://localhost:8080/manager/html"/>
<property name="username" value="admin"/>
<property name="password" value=""/>

<taskdef name="start"     classname="org.apache.catalina.ant.StartTask"/>
<taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"/>
<taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"/>

<target name="start" description="Start web application">
    <start url="${manager-url}" username="${username}" password="${password}" path="${path}" output="${tomcat-home}/webapps/start.html"/>
</target>

<target name="stop" description="Stop web application">
    <stop url="${manager-url}" username="${username}" password="${password}" path="${path}" output="${tomcat-home}/webapps/stop.html"/>
</target>

<target name="undeploy" description="Start web application">
    <undeploy url="${manager-url}" username="${username}" password="${password}" path="${path}" output="${tomcat-home}/webapps/undeploy.html"/>
</target>

当我从Eclipse运行这些目标(启动、停止、卸载)时,会得到以下输出结果:
Buildfile: C:\eclipse_3.5\eclipse\workspace\MyApp\build.xml
Trying to override old definition of datatype resources
undeploy:

BUILD FAILED
C:\eclipse_3.5\eclipse\workspace\MyApp\build.xml:85: <html>

Total time: 20 seconds

目标重定向的输出是HTML文件,指示Tomcat管理器命令成功执行,当我检查管理器时,看起来确实如此。

4个回答

2
我遇到了同样的问题,并在这里找到了答案。
问题出在你用于undeploy任务的URL上,你需要删除html。
<property name="manager-url" value="http://localhost:8080/manager/html"/>

should be:

<property name="manager-url" value="http://localhost:8080/manager"/>

我认为只有在使用Tomcat 7.0版本时才需要/html,否则构建将无法连接。 - Steve Pitchers

0

你需要更改你的URL为

<property name="manager-url" value="http://localhost:8080/manager/text"/>

您可能还需要将新用户添加到Tomcat的conf/tomcat_users.xml中,因为建议将manager-gui(HTML访问)与manager-script(文本访问)分开:

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="browser" password="xyzzy" roles="manager-gui"/>
<user username="ant" password="plugh" roles="manager-script"/>

另请参阅https://issues.apache.org/bugzilla/show_bug.cgi?id=50706


0
这是答案。不要按照文档中的说法做!自动生成的build.xml文档中建议将catalina-ant.jar复制到ant lib目录中。这就是问题的原因!将其删除,然后它就会运行。

0

你看到的错误可能与取消部署调用无关。

在第85行,你有一个 <html> 标签,这是 ant 不喜欢的,导致了失败。


<html>标签不在我的build.xml中。它在undeploy调用返回的html中。正如您所看到的,我已将输出重定向到名为undeploy.html的文件中。我将在此处粘贴其内容: http://pastebin.com/shrxYk7v正如您所看到的,html文件是管理页面状态的快照,并显示以下消息:OK - 在上下文路径/MyApp处取消部署应用程序 - vecima

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接