I'm trying to deploy a vaadin application to jetty.
But when I run jetty using start.jar
, it starts to a subfolder of
C:\Users\USERNAME\AppData\Local\Temp\jetty-0.0.0.0-8080-Application.war-....
Although I've put it into C:\Program Files\MyApp
, it always runs there - including the files it saves.
How do I tell jetty to start right where it resides, and have all files relatively to this base?
I'm on Windows 7, we're talking about the most recent, standalone jetty package.
Any idea is appreciated.
Jetty needs a working directory.
Its search order for finding a work directory is as follows:
javax.servlet.context.tempdir
attribute set, and if directory exists, use it.${jetty.base}/work
directory exists, use it (only valid for Jetty 9.1+)
${jetty.home}/work
directory exists, use it.${jetty.base}/work
org.eclipse.jetty.webapp.basetempdir
attribute set, and if the directory exists, use it.System.getProperty("java.io.tmpdir")
and use it.The easiest one is either #3 or #4, just create a work
directory underneath your ${jetty.home}
or ${jetty.base}
and restart Jetty.
The next easiest is #6, to specify your own java.io.tmpdir
when you start the JVM for Jetty.
[jetty-distribution]$ java -Djava.io.tmpdir=/var/web/work -jar start.jar
The rest require you to configure the context for that deployed webapp.
Example for Jetty 7 or Jetty 8:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath"><Property name="foo"/></Set>
<Set name="war">/var/web/webapps/foo.war</Set>
<Set name="tempDirectory">/var/web/work/foo</Set>
</Configure>
Example for Jetty 9 (just a dtd change):
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath"><Property name="foo"/></Set>
<Set name="war">/var/web/webapps/foo.war</Set>
<Set name="tempDirectory">/var/web/work/foo</Set>
</Configure>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With