I'm using Jetty 8.1.9 as an API and manually deploying by adding a WebAppContext handler to the server.
Server server = new Server();
WebAppContext webapp = new WebAppContext();
webapp.setContextPath(CONTEXT_PATH);
webapp.setWar(WEBAPP_PATH);
webapp.setExtractWAR(false);
server.setHandler(webapp);
server.start();
server.join();
If the webapp does not contain any jars in WEB-INF/lib, then this works just fine. However, if the webapp contains jars, I get the following exception:
java.lang.IllegalArgumentException: !file: jar:file:/F:/projects/jetty-example/webapps/app.war!/WEB-INF/lib/whatever.jar
at org.eclipse.jetty.webapp.WebAppClassLoader.addClassPath(WebAppClassLoader.java:245)
It works if I set webapp.setCopyWebInf(true);
Am I doing it wrong, is it a bug, or can Jetty not load libraries directly from wars?
Edit:
To provide a little more information about my setup, Jetty is embedded inside of a jar with a main class that sets everything up, similar to start.jar. This is intended to be a simplification (a facade, if you will) of a standard jetty deployment. Only specific war packages will be used, but as they are potentially optional, they are external to the executable jar. So, the directory structure looks something like the following:
/ baseDirectory
| embedded-jetty.jar
/ webapps
| myWar1.war
| myWar2.war