Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cant do mvn tomcat:deploy because of http response 405

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>
like image 271
krackmoe Avatar asked Jan 20 '13 17:01

krackmoe


2 Answers

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>
like image 112
magnusson Avatar answered Nov 02 '22 01:11

magnusson


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.

like image 1
Faerox Avatar answered Nov 01 '22 23:11

Faerox