The intersection of technology and leadership

Executable War in Maven

One of the many issues I had (have) with Maven is finding out how to use an appropriate plugin. The site documentation is normally pretty obscure, and examples are sparse. One of the activites we needed to do recently is to turn our war artifact into something that would run standalone. I’d normally use something like jetty for this but I didn’t find a way to easy bundle jetty and refer to the war within the same classpath (and still have things work).

Another tool I stumbled across was winstone (Hudson uses this beast). Wrapping this up seemed pretty easy enough. Note that the configuration below is used to start a war that won’t have dynamic JSP compilation. If you do, you can add a useJasper=true configuration and add the appropriate maven dependencies for jasper to ensure they’re available.

The result of this plugin will effectively build an executable jar, that you simply start up.

Need to add these dependencies:

Given that your project is a war package as well

<plugin>
	<groupId>net.sf.alchim</groupId>
	<artifactId>winstone-maven-plugin</artifactId>
	<executions>
		<execution>
			<goals>
				<goal>embed</goal>
			</goals>
			<phase>package</phase>
		</execution>
	</executions>
	<configuration>
		<filename>executableWebApplication.jar</filename>
	</configuration>
</plugin>

You will find this artifact built in your standard target directly.

3 Comments

  1. Marco

    it works but jsp doesn’t compile I tried with:
    java -jar target/portatile-standalone.jar –useJasper
    but I got a

    [Winstone 2011/03/01 11:27:37] – WARNING: Jasper servlet not found – disabling JSP support. Do you have all the jasper libraries in the common lib folder (see –commonLibFolder setting) ?

    even if there are dependancies for jasper (since the app with maven within eclipse works)

  2. Patrick

    If you want to do this, you probably also need to include the jasper dependencies (standard maven dependency) for compile-type assembly. I’ve never tried it though.

  3. wwerner

    This one uses jetty: http://simplericity.com/2009/11/10/1257880778509.html

    A little too shiny for my taste, but very very nice to use.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 patkua@work

Theme by Anders NorenUp ↑