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.
Because of this it is necessary to currently add some more configuration.
For example, see the Jetty example [1] and notice that there are two
init params, one to set the resource config class, and the other to set
the properties used for the class. This configures to use the package
scanning technique (rather than the default class scanning technique)
that searches classes in the package "jetty".
An alternative if still wanting to use the classpath scanning technique
is to override the default directories and have the following:
<init-param>
<param-name>com.sun.ws.rest.config.property.classpath</param-name>
<param-value>/</param-value>
</init-param>
this works for deployment using GF, i have not tried it with Jetty.
Hope this helps,
Paul.
[1]
http://wikis.sun.com/pages/viewpage.action?pageId=21725365
Lars Tackmann wrote:
> Hi
>
> I usually test my web applications using embedded jetty with code such as this:
>
> --
> @BeforeClass
> public void setUp() throws Exception {
> 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" });
> server.addHandler(webAppContext);
> server.start();
> }
>
> @AfterClass
> public void tearDown() throws Exception {
> if (server != null)
> server.stop();
> }
> --
>
> which forces jetty to look in "src/main/webapp" for my WEB-INF and
> then use my programs classpath to pick the needed classes.
> This works beautifully with Seam and Struts applications but fails
> miserably with Jersey, since it tries to pick up "src/main/webapp"
> as the base for my classpath. Resulting in:
>
> --
> WARNING: File, C:\projects\randompage\java\samples\jax-rs\bookmarking\src\main\webapp\WEB-INF\lib,
> is ignored, it not a directory, a jar file or a zip file
> Apr 22, 2008 3:42:13 PM
> com.sun.ws.rest.impl.container.config.AnnotatedClassScanner index
> WARNING: File, C:\projects\randompage\java\samples\jax-rs\bookmarking\src\main\webapp\WEB-INF\classes,
> is ignored, it not a directory, a jar file or a zip file
> --
>
> I really like to use web.xml in my unit tests since it frees my of the
> redundancy involved in configuring a servlet holder
>
> --
> ServletHolder sh = new ServletHolder(ServletContainer.class);
> // manually set init parameters below
> // :
> --
>
> So in short is there some way to get Jersey working from within Jetty
> using a existing web.xml ?
>
> Any input will be greatly appreciated.
>
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109