简体   繁体   English

Tomcat 8无法通过Ant脚本进行部署

[英]Tomcat 8 cannot deploy via Ant script

Tomcat Version: 8.0.43 Tomcat版本:8.0.43

OS: Windows 10 作业系统:Windows 10

My Deploy URL: http://localhost:8080/manager/text 我的部署URL: http:// localhost:8080 / manager / text

My user accounts appear to be setup properly as I can access the web UI just fine. 我的用户帐户似乎设置正确,因为我可以正常访问Web UI。

<?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 当我尝试在浏览器中手动访问该部署URL时,我没有问题,并且在日志中看到了

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 当我尝试通过Ant进行部署时,出现以下错误并使用401未经授权的HTTP代码登录日志

<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. 奇怪的是,使用相同的用户名和密码,我的Undeploy Ant命令可以正常工作。 So If I manually deploy my WAR I can successfully undeploy using this command 因此,如果我手动部署WAR,则可以使用此命令成功取消部署

<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. 需要注意的一件事是,成功进行手动访问和取消部署尝试的日志条目将user显示在该条目的前面。 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. 更新:看来这可能与tomcat 8 lib文件有关。 Currently I use catalina-ant, tomcat-coyote, tomcat-util JAR's in my classpath to run my ant script. 当前,我在类路径中使用catalina-ant,tomcat-coyote,tomcat-util JAR来运行我的ant脚本。 If i use the lib's provided in Tomcat 8 I have those errors above. 如果我使用Tomcat 8中提供的库,则会出现上述错误。 If I instead use the libs from an old Tomcat 7 installation I have then it works fine. 如果我改用旧的Tomcat 7安装中的库,则可以正常运行。

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 . 已知在2017年5月30日(8.0.45及更高版本)之后的所有版本的Tomcat 8.0中都将取消对身份验证的支持-请参阅问题#62809

The issue #62809 has been fixed in Tomcat 9.0.13, 8.5.35, 7.0.92. 问题#62809已在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. 在Tomcat 8.0中尚未修复此问题,因为Tomcat 8.0已经达到使用寿命。

For reference: r1796838 , r1843992 . 供参考: r1796838r1843992

at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122) 在java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:238) 在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. 上面的行号并非来自您声称的Tomcat 8.0.43,而是来自8.0.45或更高版本。 In 8.0.43 the "ostream.write(..)" call is on line 242 of AbstractCatalinaTask . 在8.0.43中,“ ostream.write(..)”调用位于AbstractCatalinaTask第242行上。 In 8.0.45+ it is on line 238. 在8.0.45+中,它位于238行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM