Tuesday, June 16, 2009

Tomcat Exploded war - cut deployment time

The time taken for a webapp to be packaged into a war, deploy and then have it unpackaged in tomcat container can be reduced. Simply have the exploded war deployed.  This could save time for developer!!



Steps to make exploded war deployment:

1. add this under pom.xml >> plugins
             
             
                org.codehaus.mojo
                tomcat-maven-plugin
                1.0-beta-1
               
                    admin
                    admin
                    <url>http://localhost:8080/manager

               

                                          


2. mvn war:exploded tomcat:undeploy tomcat:exploded
--This keeps the war exploded, undeploys the webapp context and copies over the exploded build to tomcat using the tomcat manager.


Also a better option to deploy to different servers and also generating the war ( instead of configuration above):
mvn clean install -Dmaven.test.skip=true  war:exploded tomcat:undeploy tomcat:exploded -Dmaven.tomcat.url=http://localhost:8080/manager -Dtomcat.password=admin -Dtomcat.username=admin


Refer for more http://mojo.codehaus.org/tomcat-maven-plugin/exploded-mojo.html








1 comment:

Anonymous said...

You might have issues setting up tomcat manager for the first time.

Ensure you have the following in tomcat-users.xml
[role rolename="tomcat"/]
[role rolename="manager"/]
[role rolename="admin"/]

[user username="admin" password="admin" roles="manager,tomcat,admin"/]

Remember manager role is not in the sample provided in tomcat 6. You would need to add it yourself or else tomcat manager wont work.

Using mave you can remote deploy using

cmd /c mvn clean install tomcat:redeploy -Dmaven.tomcat.url=http://localhost:8080/manager -Dtomcat.password=admin -Dtomcat.username=admin