File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Java Products and Servers and the fly likes A problem running a WAR using Jetty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "A problem running a WAR using Jetty" Watch "A problem running a WAR using Jetty" New topic

A problem running a WAR using Jetty

Jacob Biran

Joined: Jun 22, 2010
Posts: 1
When using Jetty embedded in project (not with start.jar, but with its Server object), you can add WAR support to a certain WAR file, using the setWar() method of the WebAppContext object. But the WAR will be shown as a static file you can download (kind of a zip file) in a list of the its folder contents. Unless it has the same ProtectionDomain as the project (i.e. it's somewhere inside the /src folder), then it will be executed and show its contents (index.jsp). It is because Jetty Server found out it is safe to execute the WAR since its in the same ProtectionDomain.
My problem occurred when trying to do the same when running the whole project from a Runnable JAR. Then, my WAR file happened to be located in jar:file:/.../myProj.jar!/.../myWar.war, instead of file:/.../myProj/bin/.../myWar.war. Nothing to be afraid of in terms of ClassLoader, but Jetty server founds it out as different ProtectionDomains, leading to a static display of the WAR file to download, instead of displaying its index.jsp and other content.

How can I tell Jetty to let go and execute the WAR, even though it's inside a JAR?

I agree. Here's the link:
subject: A problem running a WAR using Jetty
It's not a secret anymore!