Question

I'm trying to configure jetty to switch between different apps folders. For example: I have 2 app folders (containing WEB-INF, classes, war etc) App1 and App2. I want to create a symbolic link in linux "myapp" that points to App1 or App2 and to access my resources (ie. my app's servlet) with http://host.com/myapp/resource...

I added the following lines in my etc/webdefault.xml file to enalbe aliases, but didn't work:

<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>

<init-param>
<param-name>aliases</param-name>
<param-value>true</param-value>
</init-param>

</servlet>

Is there a way to enable this behavior ? or do I need another approach ? Basically i need a fast way to switch between versions for a production app, without major changes, or a server restart :)

Was it helpful?

Solution

Use a Context based deployment.

Create a ${jetty.home}/contexts/myapp.xml and specify the mapping you want.

<?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">/myapp</Set>
   <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/App1</Set>
</Configure>

This makes the context /myapp be served by your ${jetty.home}/webapps/App1 directory.

If you have hot deployment still enabled (it is enabled by default). Then just edit the ${jetty.home}/contexts/myapp.xml and save it, jetty will pick up the change and serve the new settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top