java - Tomcat 教程 : Why Did This Install Fail?

标签 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)

这同时使用了 example web.xmlexample build.xml在 Tomcat 站点上提供。为什么会失败,我该如何解决?

最佳答案

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

所以失败的不是构建,而是尝试部署应用程序的构建后步骤。

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

  • Create a "build.properties" file in your application's top-level source directory (or your user login home directory) that defines appropriate values for the "manager.password", "manager.url", and "manager.username" properties described above.

编辑:This可能有帮助:

You can find the role names in the web.xml file of the Manager web application. The available roles are:

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.

关于java - Tomcat 教程 : Why Did This Install Fail?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21317229/

相关文章:

java - 如果太长,文本对齐和切割

tomcat - 如何在tomcat上部署Apache Nutch -1.6?

java - 当我删除/重命名相应的 .java 文件时,是否可以告诉 maven-compiler-plugin 删除 .class 文件?

java - 无法使用 Ant 构建 JavaFX 应用程序

java - 从我的 java 代码使用基本 http 身份验证的服务器下载文件时出现问题

java - 使用 Lambda 表达式将 List 转换为新对象 Map 问题

java - 如何为 Spark 1.1.1 应用程序创建 WAR?

tomcat - 我应该为 Web 应用程序数据源使用什么 JNDI InitialContext 实现?

ant - 如果一项任务失败,则继续执行 ant 脚本

java - 正则表达式匹配空格后跟一个或多个字符