Radek
Radek

Reputation: 413

Ant re-deploy on Tomcat 8.5 failed - java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode

We have a standard (undeploy => deploy) Ant script in Eclipse on Tomcat 8.5, it works fine:

<target name="undeploy" description="undeploy from Tomcat">
    <undeploy
         failonerror="no"
         url="${tomcat-manager-url}"
         username="${tomcat-manager-username}"
         password="${tomcat-manager-password}"
         path="/${project-name}"
     />
</target>

and

<target name="deploy" description="deploy to tomcat">
    <echo>deploying from client</echo>
    <deploy 
        url="${tomcat-manager-url}"
        username="${tomcat-manager-username}"
        password="${tomcat-manager-password}"
        path="/${project-name}"
        war="file:${build-directory}/${war-file-name}"
     />
</target>

This works fine, deploy is successful:

undeploy:
 [undeploy] OK - Undeployed application at context path /project_name
deploy:
 [echo] deploying from client
 [deploy] OK - Deployed application at context path /project_name
build-and-undeploy-deploy:
BUILD SUCCESSFUL

But we don't want use stand-alone undeploy command before deploy app (because $CATALINA_BASE/conf/[enginename]/[hostname]/project_name.xml is then deleted), we woudl like re-deploy app over target deploy with parameter update="true" like in this documentation.

This script was working ok in previous version Eclipse on Tomcat 7, but not now on Tomcat 8.5. We get a strange "authentication" error: java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode:

<target name="deploy" description="deploy to tomcat"
    <echo>deploying from client</echo>
    <deploy 
        url="${tomcat-manager-url}"
        username="${tomcat-manager-username}"
        password="${tomcat-manager-password}"
        path="/${project-name}"
        war="file:${build-directory}/${war-file-name}"
        update="true"
     />
</target>

Result:

BUILD FAILED
..\build.xml:104: java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode
Total time: 922 milliseconds

Ant in Eclipse Oxygen version 1.10.1; tested on Tomcat 8.5.11/8.5.20; java version 1.8.0_144.

Upvotes: 2

Views: 1039

Answers (3)

Karl Henselin
Karl Henselin

Reputation: 1034

I found the same. This occurs for me in all versions after 8.5.15. 8.5.15 works fine. 8.5.16 and after all fail for me.

I haven't figured out from the release notes what change would have done this, or why it is occurring, but I was able to verify that it doesn't happen in 8.5.15 and does in 8.5.16.

I am removing the 127.0.0.1 gate in the Meta-inf, and I can login from a WebBrowser just fine, but when I try to use the ant task, it always fails. Are there dependency changes from 8.5.15 to 8.5.16 with the build xml?

So, you can work around by trying an older 8.5 version, and I think that maybe we should open a ticket against Tomcat.

Upvotes: 1

AnonymousAnswers
AnonymousAnswers

Reputation: 1

Please check that there is role defined in tomcat-users.xml file in conf folder of your current tomcat 8.5. Validate it against the tomcat-users.xml file of your earlier Tomcat 7.

It should contain a definition like the following:

<role rolename="manager"/>
  <role rolename="admin"/>
  <user username="admin" password="admin" roles="admin,manager"/>

Upvotes: 0

Rippalka
Rippalka

Reputation: 380

I ran into the exact same issue and couldn't find a way to properly solve it.

What I did to work around the problem is that I replaced the war tag by localWar. Instead of deploying your application using a HTTP PUT operation, it will do a GET. My understanding is that instead of sending your WAR over HTTP, it will tell the Tomcat manager to copy the file from the given location into the webapps folder.

Your file would look like:

<target name="deploy" description="deploy to tomcat"
    <echo>deploying from client</echo>
    <deploy 
        url="${tomcat-manager-url}"
        username="${tomcat-manager-username}"
        password="${tomcat-manager-password}"
        path="/${project-name}"
        localWar="file:${build-directory}/${war-file-name}"
        update="true"
     />
</target>

Hope that helps.

Upvotes: 1

Related Questions