POM.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager/html</url>
<server>myserver</server>
<path>/test</path>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
Eclipse used: Eclipse indigo 3.7 with m2e plugin
modified
Tomcat7/conf/tomcat-users.xml
<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>
Context.xml
Tomcat7/conf/context.xml, change <context>
to
<Context antiJARLocking="true" antiResourceLocking="true">
under apache-maven\conf\settings.xml
add following entry under server tag:
<servers>
<server>
<id>myserver</id>
<username>admin</username>
<password>admin</password>
</server>
Start tomcat server.
target run: tomcat:deploy and tomcat:undeploy
getting following error:
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project test: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/html/deploy?path=%2Ftest&war=&update=true -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
project name: test
war file name: test-1.0-SNAPSHOT.war
similar issue found but didnot get much use: Tomcat-maven-plugin 401 error
Best Answer
Though a late answer , someone might find this useful. If you are using maven3 and tomcat7.The below method worked for me.I was not aware of the change in application manager endpoint in tomcat7.
Tomcat7 has changed its deployment end point from
http://tomcatserver:8080/manager/html
tohttp://tomcatserver:8080/manager/text
.So my pom.xml will be
In tomcat-users.xml
In maven settings.xml
In context.xml , though this is optional and is not related to maven3 deployment to tomcat7 ,sometimes jar locking might happen,so to be on the safer side.
Now issue
Remember to start tomcat before maven deployment.
If deployment is success , your application will be available at