user3220334
user3220334

Reputation: 1013

Tomcat Tutorial: Why Did This Install Fail?

I am working through the Tomcat tutorial here and in particular the section of installing the hello world war file to the server container

Upon ant install I get this error:

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)

This is using both the example web.xml and the example build.xml provided on the Tomcat site. Why is this failing and how do I fix this?

Upvotes: 1

Views: 93

Answers (2)

user3220334
user3220334

Reputation: 1013

Ok, the solution is to make the role "manager-script" in the tomcat-users.xml. Which is terribly unclear, but so be it. That makes it sound like a script that needs to be run.

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

Upvotes: 0

eis
eis

Reputation: 53462

HTTP 401 is Unauthorized. You haven't configured/used the correct credentials.

So it's not bulding that fails, it's the post-build step trying to deploy your application.

Maybe you did not follow 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.

Edit: This might be of help:

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.

Upvotes: 1

Related Questions