简体   繁体   中英

Why does Eclipse report BUILD FAILED when Ant Tomcat task seems to be successful?

When running Ant targets with tomcat manager commands they appear to be successful, but report BUILD FAILED.

Here are the relevant parts of my 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>

When I run these targets (start, stop, undeploy) from eclipse I get output like the following:

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

the output redirected by the targets are html files that indicate that the Tomcat manager command was successful, and when I check the manager it seems like it was.

I had the same problem and discovered the answer here

The problem is the URL that you're using for the undeploy task; you need to remove the html.

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

should be:

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

You need to change your URL to

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

You may also need to add a new user to Tomcat's conf/tomcat_users.xml , because it's recommended to keep manager-gui (HTML access) separate from manager-script (text access):

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

See also https://issues.apache.org/bugzilla/show_bug.cgi?id=50706

The error you see is probably unrelated to the undeploy invocation.

At line 85 you have a <html> tag which ant dislikes and cause the failure.

Here's the answer. Do NOT do what it says in the docs! The docs for the auto generated build.xml say to copy the catalina-ant.jar to the ant lib dir. THAT IS WHAT IS CAUSING THE PROBLEM! Remove it and whola, it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM