When developing web apps with Maven the de facto standard for running the app is to use the excellent Maven Jetty Plugin which runs the project in an embedded Jetty server. When configured, it can either run the project from the war file directly via mvn jetty:run or in exploded mode where the war is unpacked before being run (mvn jetty:run-exploded). This noticably speeds up development as there is no need to manually deploy the artifact to a server.
But if the production system does not run on Jetty but on Tomcat you might run into some problems:
- Some redirects from AJAX calls do work on Jetty but do not work on Tomcat
- When submitting some forms on Jetty the parameters get lost
The latter can be noticed when running OpenCms on Jetty: Saving from the editor causes an error because the parameters are not available to OpenCms.
Fortunately there is a viable alternative: The Tomcat Maven Plugin. Besides providing several options to deploy artifacts to an external server it can also be run in an embedded mode.
This is how the plugin is configured:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> </plugin>
It can be run using mvn tomcat:run and mvn tomcat:run-war for running in unpacked war mode.
Using this plugin you can be sure that the features your servlet container provides in production are the same during development.