I'm trying to make an "executable" war file (java -jar myWarFile.war) that will start up a jetty webserver that hosts the webapp contained in the war file I executed.
I found a page that described how to make what I'm looking for:
http://eclipsesource.com/blogs/2009/10/02/executable-wars-with-jetty/
however, following that advice along with how I think I'm supposed to make an executable jar (war) isn't working.
I have an ant task creating a war with a manifest that looks like:
Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.1 Created-By: 1.5.0_18-b02 (Sun Microsystems Inc.) Main-Class: Start
The contents of the war look like:
> Start.class
> jsp
> build.jsp
> META-INF
> MANIFEST.MF
> WEB-INF
> lib
> jetty-6.1.22.jar
> jetty-util.6.1.22.jar
When I try to execute the .war file, the error is:
Exception in thread "main" java.lang.NoClassDefFoundError: org/mortbay/jetty/Handler
Caused by: java.lang.ClassNotFoundException: org.mortbay.jetty.Handler
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Start. Program will exit.
There appears to be two errors here, one where it seems the jar files can't be found and one where the Start.class can't be found.
To fix the first one, I put the jetty .jar files in the base of the war and tried again, same error. I also tried adding the WEB-INF/lib/ to the Class-path attribute of the manifest. That did not work either.
Does anyone have any insight as to what I'm doing right/wrong and how I can get this executable war up and running?