Embedded Tomcat command line config

The Tomcat maven plugin is great. It lets you build executable Jar files from your regular maven web project.

With the embedded Tomcat you loose the usual conf directory, so you need to think a bit about putting the config some where. You can specify it inline with the code like so:

Maven plugin config for embedded Tomcat

This is ok, until you want to run multiple server instances on different ports etc

Properties can also be overriden on the command line. However, this does not seem to work properly. Some digging around the plugin code revealed that the plugin runner (org.apache.tomcat.maven.runner.Tomcat7Runner) looks for the server.xml first. If, found it ignores other flags! So if you need to configure your Jar with embedded Tomcat, you need to provide the server.xml on the command line like this:

-serverXmlPath qaServer.xml

Now you can start multiple instance with the same Jar and safely externalize server config.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s