我正在追随春天tutorial。在那它它控制tomcat与蚂蚁任务。之前我遇到的问题很少,因为tomcat 7 manager app与以前的版本不同。但我能够解决它们。现在,ant listtask工作正常。但其他人不是。例如,ant starttask返回此错误。
start-webapp:
BUILD FAILED
C:\Users\rsenarath\workspace\myspringapp\build.xml:108: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/text/start?path=%2Fmyspringapp
但是当我在浏览器上复制网址(http:// localhost:8080 / manager / text / start?path =%2Fmyspringapp)时,它会要求输入用户名密码,并且回复时没有问题如下。
OK - Started application at context path /myspringapp
有人可以帮助我。我的build.properties如下所示
appserver.name=tomcat
appserver.home=C:/Users/rsenarath/apache-tomcat-7.0.34
appserver.lib=${appserver.home}/lib
appserver.bin=${appserver.home}/bin
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager/text
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret
和ans任务如下
<path id="catalina-ant-classpath">
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
<include name="tomcat-coyote.jar"/>
<include name="tomcat-util.jar"/>
</fileset>
<fileset dir="${appserver.home}/bin">
<include name="tomcat-juli.jar"/>
</fileset>
</path>
<taskdef name="catalina-deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-list" classname="org.apache.catalina.ant.ListTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-resources" classname="org.apache.catalina.ant.ResourcesTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-start" classname="org.apache.catalina.ant.StartTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-stop" classname="org.apache.catalina.ant.StopTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-undeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="catalina-ant-classpath"/>
<target name = "stop-webapp">
<catalina-stop url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${name}"
failonerror="false"/>
</target>
<target name = "start-webapp">
<catalina-start url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${name}"/>
</target>
<target name="list-webapp" description="List Tomcat applications">
<catalina-list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
答案 0 :(得分:1)
在start-webapp和stop-webapp目标中,您将这些变量用于user / pass:
tomcat.username
tomcat.password
但是在你的配置数据中你设置了这些:
tomcat.manager.username
tomcat.manager.password
因此,当您运行start-webapp目标时,可能没有设置用户名和密码,因此401.也许您可以更新开始和停止目标中的变量名称以匹配配置。