Reputation: 1122
Tomcat Version: 8.0.43
OS: Windows 10
My Deploy URL: http://localhost:8080/manager/text
My user accounts appear to be setup properly as I can access the web UI just fine.
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="user" password="pass" roles="manager-gui,manager-script"/>
</tomcat-users>
When I try to manually access that deploy URL in a browser I have no problems and I see this in my logs
user [08/Oct/2018:12:51:15 -0700] "GET /manager/text/deploy?path=/apc HTTP/1.1" 200 69
When I try to deploy via Ant I get the following error and log entry with a 401 unauthorized HTTP code
<target name="deploy" description="Install web application" depends="dist">
<deploy url="http://localhost:8080/manager/text" username="user" password="pass"
path="/apc" war="dist/apc.war"/>
</target>
java.io.IOException: Error writing request body to server
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:3536)
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3519)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:238)
at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:194)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:834)
at org.apache.tools.ant.Main.startAnt(Main.java:223)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Suppressed: java.io.IOException: insufficient data written
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.close(HttpURLConnection.java:3558)
at java.io.FilterOutputStream.close(FilterOutputStream.java:159)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:241)
... 17 more
- [08/Oct/2018:12:52:14 -0700] "PUT /manager/text/deploy?path=%2Fapc HTTP/1.1" 401 2473
The strange part is that my Undeploy Ant command works just fine using the same username and password. So If I manually deploy my WAR I can successfully undeploy using this command
<target name="undeploy" description="Remove web application">
<undeploy url="http://localhost:8080/manager/text" username="user" password="pass"
path="/apc"/>
</target>
user [08/Oct/2018:12:47:34 -0700] "GET /manager/text/undeploy?path=%2Fapc HTTP/1.1" 200 61
So it seems that my username and password are correct, but for whatever reason the deploy doesn't recognize it as valid
One thing to note is that the log entries for my successful manual access and undeploy attempts show the user
in front of the entry. The unsuccessful log entry for the deploy shows a -
instead. Not sure what that means but might be important.
UPDATE: It appears it might have something to do with the tomcat 8 lib files. Currently I use catalina-ant, tomcat-coyote, tomcat-util JAR's in my classpath to run my ant script. If i use the lib's provided in Tomcat 8 I have those errors above. If I instead use the libs from an old Tomcat 7 installation I have then it works fine.
Upvotes: 1
Views: 779
Reputation: 3946
Authentication support is known to be broken in all version of Tomcat 8.0 later than 2017-05-30 (8.0.45 and later) -- see issue #62809.
The issue #62809 has been fixed in Tomcat 9.0.13, 8.5.35, 7.0.92. It has not been fixed in Tomcat 8.0, as Tomcat 8.0 has already reached End of Life.
For reference: r1796838, r1843992.
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:238)
The line numbers above are not from Tomcat 8.0.43 as you are claiming, but from 8.0.45 or later.
In 8.0.43 the "ostream.write(..)" call is on line 242 of AbstractCatalinaTask
. In 8.0.45+ it is on line 238.
Upvotes: 2