users@jersey.java.net

ClassNameResourceConfig.PROPERTY_CLASSNAMES ignored with Grizzly Web and EmbeddedGlassFish test containers

From: Naresh <Srinivas.Bhimisetty_at_Sun.COM>
Date: Mon, 12 Oct 2009 14:50:03 +0530

Hi,

  it is observed that the property
ClassNameResourceConfig.PROPERTY_CLASSNAMES is being ignored when
I try running the tests using the GrizzlyWeb test container and the
EmbeddedGF test container.

Though I set this property in the init-param, at runtime Jersey tries to
initialize ClasspathResourceConfig, this however works fine with LW HTTP
Server and Grizzly server.

The following output is seen when I try running the test:

-------------------------------------------------------------------------------------------------
12 Oct, 2009 2:37:42 PM com.sun.jersey.api.core.ClasspathResourceConfig init
INFO: Scanning for root resource and provider classes in the paths:
  
/home/naresh/workspace/tango/qe-tests/jersey-tests/core-tests/coretest2/WEB-INF/lib
  
/home/naresh/workspace/tango/qe-tests/jersey-tests/core-tests/coretest2/WEB-INF/classes
12 Oct, 2009 2:37:42 PM
com.sun.jersey.server.impl.container.config.AnnotatedClassScanner index
WARNING: File,
/home/naresh/workspace/tango/qe-tests/jersey-tests/core-tests/coretest2/WEB-INF/lib,
is ignored, it not a directory, a jar file or a zip file
12 Oct, 2009 2:37:42 PM
com.sun.jersey.server.impl.container.config.AnnotatedClassScanner index
WARNING: File,
/home/naresh/workspace/tango/qe-tests/jersey-tests/core-tests/coretest2/WEB-INF/classes,
is ignored, it not a directory, a jar file or a zip file
12 Oct, 2009 2:37:42 PM
com.sun.jersey.server.impl.application.WebApplicationImpl initiate
INFO: Initiating Jersey application, version 'Jersey: 1.1.4-ea-SNAPSHOT
10/07/2009 03:16 PM'
12 Oct, 2009 2:37:42 PM
com.sun.jersey.server.impl.application.WebApplicationImpl
processRootResources
SEVERE: The ResourceConfig instance does not contain any root resource
classes.
12 Oct, 2009 2:37:42 PM com.sun.grizzly.http.servlet.ServletAdapter service
SEVERE: service exception:
com.sun.jersey.api.container.ContainerException: The ResourceConfig
instance does not contain any root resource classes.
    at
com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:810)
    ...

-------------------------------------------------------------------------------------------------

Here is an extract from my test's code:

-----------------------------------------------------------------------------------------------
private static Map<String, String> initParams;

    static {
        initParams = new HashMap<String, String>();
        // some bug here
        initParams.put(ClassNamesResourceConfig.PROPERTY_CLASSNAMES,
"com.sun.jersey.qe.tests.core.MyResource;");
        //
initParams.put(PackagesResourceConfig.PROPERTY_PACKAGES,
"com.sun.jersey.qe.tests.core"); -------------------------> this works
fine
       //
initParams.put(ClasspathResourceConfig.PROPERTY_CLASSPATH,
".");
--------------------------> this too works fine
        initParams.put(ResourceConfig.FEATURE_DISABLE_WADL, "true");
    }

    public MyResourceTest() {
       super(new WebAppDescriptor.Builder(initParams)
               .contextPath("coretest2")
               
.servletClass(com.sun.jersey.spi.container.servlet.ServletContainer.class)
               .build());
    }
-----------------------------------------------------------------------------------------------

    The issue is seen only with
ClassNameResourceConfig.PROPERTY_CLASSNAMES.
The tests however pass when PackagesResourceConfig.PROPERTY_PACKAGES and
ClasspathResourceConfig.PROPERTY_CLASSPATH are used.

   Is it possibly an issue with ClassNameResourceConfig +
Grizzly/EmbeddedGF?

Thanks,
Naresh