users@jersey.java.net

Re: [Jersey] ClassNameResourceConfig.PROPERTY_CLASSNAMES ignored with Grizzly Web and EmbeddedGlassFish test containers

From: Naresh <Srinivas.Bhimisetty_at_Sun.COM>
Date: Tue, 13 Oct 2009 15:42:42 +0530

Hi Paul,

   that commit had fixed the problem with transformation.

But, in my case I'm working with WebAppDescriptor (test), and see that
the property PROPERTY_CLASSNAMES is ignored and ClasspathResourceConfig
is initialized when I try using the Grizzy Web test container type.

The test in the attached zip file shows the behavior, just unzip it and
do *mvn test*.

Thanks,
Naresh

Paul Sandoz wrote:
> Hi Naresh,
>
> From your commit you found out what the problem is :-) but i think it
> is worth updating so that others are aware.
>
> The problem is with the Jersey test framework and the transformation
> of a Web app (test) description into a low level (test) description
> that is required for some test containers.
>
> Paul.
>
> On Oct 12, 2009, at 11:20 AM, Naresh wrote:
>
>> 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
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>