I was hoping to combine/embed Tomcat and my web app as onejar aka fat jar but I'm not sure if its possible. Its possible with Jetty using the Maven Shade plugin and Winstone but I tried something similar with Tomcat 7 and could not get it to load properly. The goal is to be able to do something like: java -jar mywebapp.jar
.
The problem is that Tomcat wants to load things from the file system and not from the classpath. That is you can embed Tomcat but it will expect your WAR files to be available as files.
I tried many of the techniques on previous SO Posts for embedding Tomcat 6 & 7. While I can get it embedded and started it can't access my app.
I guess one option is having the JAR on boot unzip itself so that AppBase
and DocBase
are files on the file system. I haven't tried that yet but will.
There is a duplicate of the question here that I finally found: Self-contained war file with Tomcat embedded? (please vote to close as duplicate)
java -jar my-webapp.jar
. – Gelhar