You don’t need to install Tomcat, JBoss or any other web server in order to run a Java web application (.war file)!
If your project is configured with a Maven
pom.xml and the module has
<packaging>war</packaging>, you can just add this little piece of XML inside the pom’s
net.sf.alchim winstone-maven-plugin embed package
Then, when you run…
…winstone-maven-plugin will automatically create a
*-standalone.jar file for you, which contains your web application.
You can run that .jar file as a standalone application, which runs your included web application on port 8080 by default:
java -jar target/*-standalone.jar
No web server installation necessary! No external files required! (You don’t even need the .war file anymore.)
The resulting .jar file is actually the servlet container Winstone, with your .war file deployed inside it.
There are more configuration options on winstone-maven-plugin’s usage page.
I want to disable some default features of Winstone for security reasons, because they are not needed: ajp13 listener on a separate port, servlet invoker and directory listings. This is the complete plugin configuration I usually use myself:
net.sf.alchim winstone-maven-plugin 1.2 httpPort 8080 ajp13Port -1 controlPort -1 directoryListings false useInvoker false embed package
You can temporarily override these configuration parameters if you like, using command-line options when executing the standalone .jar file. Find them with
--help when you run the .jar.