Tomcat教程:为什么安装失败?

时间:2014-01-23 19:08:57

标签: java tomcat ant

我正在处理Tomcat教程here,特别是the section of installing the hello world war file to the server container

安装ant后,我收到此错误:

BUILD FAILED
java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/text/deploy?path=%2Ftomcat-tutorial&war=file%3A%2F%2F%2Fhome%2Fdavid%2FIdeaProjects%2Ftomcat-tutorial%2Fbuild
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:230)
at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:196)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

这是使用Tomcat站点上提供的example web.xmlexample build.xml。为什么会失败,我该如何解决这个问题呢?

2 个答案:

答案 0 :(得分:1)

HTTP 401未经授权。您尚未配置/使用正确的凭据。

因此,这不是失败的结果,而是尝试部署应用程序的构建后步骤。

也许你没有关注this instruction for ant file

  
      
  • 在应用程序的顶级创建“build.properties”文件   定义的源目录(或您的用户登录主目录)   “manager.password”,“manager.url”和。的适当值   “manager.username”属性如上所述。
  •   

修改:This可能有所帮助:

  

您可以在Manager Web的web.xml文件中找到角色名称   应用。可用的角色是:

manager-gui — Access to the HTML interface.
manager-status — Access to the "Server Status" page only.
manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.
manager-jmx — Access to JMX proxy interface and to the "Server Status" page.

答案 1 :(得分:0)

好的,解决方案是在tomcat-users.xml中创建角色“manager-script”。这是非常不清楚的,但也是如此。这使得它听起来像需要运行的脚本。

  <user username="manager" password="manager" roles="manager-script"/>