users@jersey.java.net

Re: Jersey, Jetty and web.xml

From: Lars Tackmann <lars_at_randompage.org>
Date: Tue, 20 May 2008 14:42:23 +0200

On Wed, Apr 23, 2008 at 12:11 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> Hi Lars,
>
> The main issue is that the default configuration (nothing in the web.xml)
> assumes a standard Web deployment configuration where jars and classes
> reside in resolved directories "/WEB-INF/lib" and "/WEB-INF/classes"
> respectively.

Hi Paul and sorry for the late answer.

None of these approaches did work. Setting the initparameters on the
WebApp (like below) does not work since they are ignored when the
web.xml is scanned:

--Not Working--
server = new Server(port);
WebAppContext webAppContext = new WebAppContext("src/main/webapp", "/");
webAppContext.setConfigurationClasses(new String[] {
        "org.mortbay.jetty.webapp.WebInfConfiguration",
        "org.mortbay.jetty.webapp.WebXmlConfiguration" });
Map<String, String> initParams = new HashMap<String,String>();
initParams.put("com.sun.ws.rest.config.property.resourceConfigClass",
"com.sun.ws.rest.api.core.PackagesResourceConfig");
initParams.put("com.sun.ws.rest.config.property.packages",
"org.randompage.samples.jaxrs.bookmarking.resources");
webAppContext.setInitParams(initParams);
server.addHandler(webAppContext);
server.start();
--
and adding the following:
--
<init-param>
	<param-name>
	       com.sun.ws.rest.config.property.classpath
	</param-name>
	<param-value>/</param-value>
</init-param>
--
to web.xml only resolved in the maven java (src/main/java) folder
getting used for classpath, instead its target folder (which contains
the .class files). So for now the only working solution is to wire the
servlet by hand (or somehow figure out how to pass init paramters to
WebAppContext that overrides/extends those already in web.xml).
Anyway thanks for the hints.
-- 
Yours sincerely
Lars Tackmann