Deploy a javaee6 war in tomcat7 using maven

Recently, I'm trying to deploy a simple web application (war) in tomcat7 but it seems the old maven way of deploying a war will not work on it.

The plugin I used to use for tomcat6 is:

But it doesn't work for tomcat7 server. After googling, I found a new plugin for deploying in tomcat7: And so here's how I use the new plugin: 1.) Add the ff lines in your maven's settings.xml, usually found in %user%/.m2 folder.
2.) Modify tomcat's 7 tomcat-users.xml file, which can be found inside "%tomcat_installation%/config, and add the ff lines:
<role rolename="manager-gui"/>
<role rolename="manager-script"/> 
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
Take note that manager roles has been broken down into 4 roles as you can see. 3.) In your pom.xml file, add these repository and plugin repository:

  <name>Apache Snapshots</name>
4.) Then, what I usually does is to create a development profile where I can set the deployment mechanism in my local machine, in this case using the tomcat7 maven plugin:
Note that the url needs the additional /html, as it's updated by apache, otherwise you will get the error: "403 access denied" 5.) You can now invoke the tomcat7 deploy command as documented by the link in the top of this writing.
mvn tomcat7:deploy
Deploy a javaee6 war in tomcat7 using maven Deploy a javaee6 war in tomcat7 using maven Reviewed by Edward Legaspi on Monday, July 16, 2012 Rating: 5

1 comment:

ramasrinu said...

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-SNAPSHOT:deploy (default-cli) on project rest-sample: Cannot invoke Tomcat manager: http://localhost:8085/manager/html/deploy?path=%2Frest-sample -> [Help 1]

Powered by Blogger.