cant do mvn tomcat:deploy because of http response 405

一个人想着一个人 提交于 2019-12-07 06:24:13

问题


I am running a Tomcat 7 as a windows service. And i want to do mvn:tomcat deploy in my projects root directory.

But all the time this error appears, can you help me with this plz?

[INFO] Deploying war to http://localhost:8080/opendata
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.493s
[INFO] Finished at: Sun Jan 20 18:48:30 CET 2013
[INFO] Final Memory: 15M/39M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy
(default-cli) on project opendata: Cannot invoke Tomcat manager: Server returned
 HTTP response code: 405 for URL: http://localhost:8080/manager/deploy?path=%2Fo
pendata&war= -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

I got the following section in my pom file:

<build>
        <finalName>opendata</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <server>myserver</server>
                </configuration>
                <version>1.1</version>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

回答1:


Two things needed to get this to work;

  • a tomcat user with the role manager-script in tomcat-users.xml
  • specifying the url for deployment to something ending with manager/text.

That's it. See example conf for pom.xml below. And don't forget to use tomcat7:redeploy so you don't have to cycle undeploy/deploy.

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://your-server:8080/manager/text</url>
        <username>a-username</username>
        <password>a-password</password>
        <path>/a-path</path>
    </configuration>
</plugin>



回答2:


I ran into a similar issue today - the 405 error can be caused by Tomcat not accepting PUT requests. This can be allowed by configuring Tomcat's web.xml (typically found in %TOMCAT%\conf\web.xml), and adding the following init-param:

<init-param>
    <param-name>readonly</param-name>
    <param-value>false</param-value>
</init-param>

You might also need to add an admin user to the tomcat-users.xml. See here for more details.



来源:https://stackoverflow.com/questions/14427351/cant-do-mvn-tomcatdeploy-because-of-http-response-405

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!