dev@jersey.java.net

Re: [Jersey] NullPointerException in DefaultResourceConfig

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 05 Sep 2008 14:04:17 +0200

On Sep 5, 2008, at 1:49 PM, Matt Brozowski wrote:

>
>
> WebLogic servlet does not support class scanning of the WEB-INF/lib
> files as required by the Jersey servlet, namely
> ServletContext.getRealPath returns a null value.
>
> So how would one use Jersey then on a system that doesn't do this?
>

Use the package scanning configuration. If that does not work you need
to either:

1) Be explicit about your resource classes and point to a Application
implementation that references those; or

2) Have an application server specific Application implementation that
knows how to scan for classes in it's own
     environment.

The JavaDoc of com.sun.jersey.api.core.ResourceConfig (see the string
constants for properties) and the
com.sun.jersey.api.core.PackagesResourceConfig provide more details.

The samples make use of the package scanning configuration, here is
the web.xml of the helloworld-webapp [1] sample:

<web-app version="2.4">
     <servlet>
         <servlet-name>Jersey Web Application</servlet-name>
         <servlet-
class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
class>
         <init-param>
             <param-name>com.sun.jersey.config.property.packages</
param-name>
             <param-value>com.sun.jersey.samples.helloworld.resources</
param-value>
         </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>
     <servlet-mapping>
         <servlet-name>Jersey Web Application</servlet-name>
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
</web-app>

Paul.

[1] http://download.java.net/maven/2/com/sun/jersey/samples/helloworld-webapp/0.11-ea-SNAPSHOT/helloworld-webapp-0.11-ea-SNAPSHOT-project.zip