users@jersey.java.net

RE: [Jersey] web application resource root class in WEB-INF/lib

From: Saavedra, Gisella <gsaavedra_at_navis.com>
Date: Wed, 17 Jun 2009 15:20:54 -0700

I commented out all the init parameters for the jersey servlet, and my classes were found and loaded. It searches WEB-INF/lib and WEB-INF/classes.

 See log output below.

 

So, I would consider this scenario an issue worth investigating on your side. I don’t see a good reason why I have to edit the default application server policy file. Even more, I may not want my particular application to load all resource packages it finds. [I’ll take a look at the workaround… implement Application?]

 

The PackagesResourceConfig (when specified as init parameter) should find the classes as does the ClasspathResourceConfig that succeeds.

 

I checked the tomcat documentation for Tomcat 5.5 Servlet/JSP Container

and there is information about the Java SecurityManager. The catalina.policy file says

 

// a web application will be given a read FilePermission

// and JndiPermission for all files and directories in its document root.

 

 

I also found in the catalina.properties file, the following example, but this if needed for jersey implies customizing this file for an application:

// The permissions granted to the context WEB-INF/classes directory

// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/classes/-" {

// };

 

 

 

--- Log output when init params for jersey servlet are commented out –

 

Jun 17, 2009 10:15:15 AM com.sun.jersey.api.core.ClasspathResourceConfig init

INFO: Scanning for root resource and provider classes in the paths:

  C:\N4\sandbox-dev\tools\tomcat-5.5\webapps\sandbox\WEB-INF\lib

  C:\N4\sandbox-dev\tools\tomcat-5.5\webapps\sandbox\WEB-INF\classes

Jun 17, 2009 10:15:44 AM com.sun.jersey.api.core.ClasspathResourceConfig init

INFO: Root resource classes found:

  class com.navis.framework.rest.resources.LogListResource

  class com.navis.framework.rest.resources.LogBundle

 

 

From: Gisella%20Saavedra%20%5Bgisellas%40yachay.net%5D [mailto:gisellas_at_comcast.net]
Sent: Wednesday, June 17, 2009 3:06 PM
To: Saavedra, Gisella
Subject: Fwd: [Jersey] web application resource root class in WEB-INF/lib

 


----- Forwarded Message -----
From: "Paul Sandoz" <Paul.Sandoz_at_Sun.COM>
To: users_at_jersey.dev.java.net
Sent: Wednesday, June 17, 2009 3:28:18 AM GMT -08:00 US/Canada Pacific
Subject: Re: [Jersey] web application resource root class in WEB-INF/lib

Hi,

 

It looks like the the class loader that is being used is only configured to load classes from the WEB-INF/classes directory.

 

Is there any way to configure, via tomcat, to configure the class loader to load from "WEB-INF/classes" and "WEB-INF/lib" ?

 

I tried a quick test with Glassfish v3 Prelude and it works fine picking up classes in "WEB-INF/classes" and "WEB-INF/lib"

 

 

Just curious if you remove you init params from your web.xml then class scanning should kick in and it will try and scan for stuff in "WEB-INF/classes" and "WEB-INF/lib", i wonder if that works.

 

A work around is to define your own concrete implementation of javax.ws.rs.Application and explicitly declare your resource classes.

 

Paul.

 

 

On Jun 16, 2009, at 7:44 PM, Saavedra, Gisella wrote:

         

         

        I am enclosing the image of the scan() call (jersey_package_scan.png for .class files in WEB-INF/lib/xxx.jar). At the point that

        Enumeration<URL> urls = classloader.getResources("com/navis/framework/rest/resources");

        is called, the URL classpath points to the tomcat 5.5 server path. That is what it looks like.

        urls.hasMoreElements() returns false (no elements).

         

        I have the Jersey jars in WEB-INF/lib.

        I am using

        jersey-client-1.1.0-ea.jar

        jersey-server-1.1.0-ea.jar

        jersey-core-1.1.0-ea.jar

         

        The jaxb- 2.1.x libs

        The jsr311-api-1.1.jar, activation, asm, persistence.

         

         

        When I put the .class files under WEB-INF/classes, my application works. I have enclosed a second image showing that the package is found in the WEB-INF/classes directory (jersey_package_scan_class_dir.png for .class files in WEB-INF/classes) .

         

        The problem is that we do deliver our application in .jar files, so I really need to resolve this problem.

         

        Any suggestion, please I will appreciate.

         

        Thanks.

         

         

         

Gisella Saavedra
Sr. Software Engineer
gsaavedra_at_zebra.com

        

<image001.gif>

1000 Broadway, Suite 150, Oakland, CA 94607 | T+1 510 267 5123 T Main+1 510 267 5000 F+1 510 267 5100 | http://www.zebra.com/zes

        

         

         

        <jersey_package_scan_class_dir.png><jersey_package_scan.png>

        ---------------------------------------------------------------------
        To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
        For additional commands, e-mail: users-help_at_jersey.dev.java.net