Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A problem running a WAR using Jetty  RSS feed

Jacob Biran
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!