Setting embedded Jetty war from classpath

805 Views Asked by At

How I can set a war in an embedded jetty in a way that it can load from a classpath. Following is my current code snippet

webAppContext.setWar("hello.war");

Context :- I want to secure my code other than obfuscation.so, I used Jetty to create a runnable jar and subsequently i used winrun4j to create an exe wrapper. The exe works fine when war file is found at same level but not otherwise even though i've embedded the war in winrun4j exe.

Problem:- Is there any way that i can set the war in a way that it can pick it up from classpath rather than some pre-defined path.

Hope i communicated the problem statement in a lucid way.

Thankyou.

1

There are 1 best solutions below

1
PeterMmm On

I came around the same and I always extract the war to a temporary location and then use the absolute path;

webAppContext.setWar("/path/to/temp/tmp262622522.war");

In any case Jetty will extract the war to a temporary location too, when starting the web app.