users@jersey.java.net

[Jersey] Re: Test Grizzly 2 not picking up Provider classes

From: Gary Moore <gary.moore_at_gmail.com>
Date: Thu, 5 May 2011 10:45:42 -0400

What local network resources did you need access too? We have our own
Maven repo but that is public. It goes down often and in that case
the Maven build will hang. The tests won't run unless you config a
mysql DB called 'ATHENA-Test' to test against. Was there anything
else?

The contextParam javax.ws.rs.Application points to AthenaWebConfig.
AthenaWebConfig extends PackagesResourceConfig. AthenaWebConfig
called super("org.fracturedatlas.athena") as the base package for
Provider classes.

http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/PackagesResourceConfig.html#PackagesResourceConfig(java.lang.String...)

See the top file of the gist I posted: https://gist.github.com/955347

You comments make it sound like this

.Builder("org.fracturedatlas.athena.web.resource")

will override or conflict with this:

.contextParam("javax.ws.rs.Application",
"org.fracturedatlas.athena.web.config.AthenaWebConfig")

Finally, I made the change you suggested:

     super(new
WebAppDescriptor.Builder("org.fracturedatlas.athena.web.resource",
"org.fracturedatlas.athena.web.exception",
"org.fracturedatlas.athena.web.serialization")
       .contextPath("tix")
       .contextParam("contextConfigLocation",
"classpath:testApplicationContext.xml")
       .servletClass(SpringServlet.class)
       .contextListenerClass(ContextLoaderListener.class)
       .contextParam("javax.ws.rs.Application",
"org.fracturedatlas.athena.web.config.AthenaWebConfig")
       .build());

And got the same failing test results.

Thanks a lot for your help. Next week, I'll get a fresh Maven test
project together to reproduce the problem and email the list then.

Thanks,
Gary

On Thu, May 5, 2011 at 5:40 AM, Pavel Bucek <pavel.bucek_at_oracle.com> wrote:
> Hello,
>
> your project is kind of difficult to reproduce locally, its impossible to
> build it without access to your local network resources so I tried to strip
> it down but that didn't go well too..
>
> I looked into source code and I saw this in your tests base class:
>
>    public BaseTixContainerTest() {
>
>      super(new
> WebAppDescriptor.Builder("org.fracturedatlas.athena.web.resource")
>        .contextPath("tix")
>        .contextParam("contextConfigLocation",
> "classpath:testApplicationContext.xml")
>        .servletClass(SpringServlet.class)
>        .contextListenerClass(ContextLoaderListener.class)
>        .contextParam("javax.ws.rs.Application",
> "org.fracturedatlas.athena.web.config.AthenaWebConfig")
>        .build());
>
> your providers are in
> org.fracturedatlas.athena.web.(exception|serialization).. so you need to add
> these packages too (Jersey scans recursively from
> "org.fracturedatlas.athena.web.resource" thus it should not ever reach your
> providers (they are not part of this or sub packages).
>
> I'm just wondering how is possible that it works with grizzly 1.. testcase
> would be really great.
>
> Anyway, if you add mentioned packages to Builder inicialization, it should
> work with grizzly 2 too.
>
>      super(new
> WebAppDescriptor.Builder("org.fracturedatlas.athena.web.resource",
> "org.fracturedatlas.athena.web.exception",
> "org.fracturedatlas.athena.web.serialization")
>        .contextPath("tix")
>        .contextParam("contextConfigLocation",
> "classpath:testApplicationContext.xml")
>        .servletClass(SpringServlet.class)
>        .contextListenerClass(ContextLoaderListener.class)
>        .contextParam("javax.ws.rs.Application",
> "org.fracturedatlas.athena.web.config.AthenaWebConfig")
>        .build());
>
> Please let me know whethet it helped.
>
> Thanks,
> Pavel
>
>
> On 5/4/11 5:03 PM, Gary Moore wrote:
>>
>> No test case yet, but here are more details:
>>
>> My AppConfig class, POM, Test setup, and console output for Jersey 1.6
>> with Grizzly 1.  All tests pass.  The provider classes get picked up
>> fine here.
>>
>> https://gist.github.com/955347
>>
>> The POM and console output for Jersey 1.6 with Grizzly 2.  None of the
>> providers get picked up here.  The only change is changing
>> jersey-test-framework-grizzly->jersey-test-framework-grizzly2
>>
>> https://gist.github.com/955359
>>
>> An example of one of our providers:
>>
>>
>> https://github.com/fracturedatlas/ATHENA/blob/master/core/web-resources/src/main/java/org/fracturedatlas/athena/web/serialization/JsonTicketSerializer.java
>>
>> Thanks,
>> Gary
>>
>> On Tue, May 3, 2011 at 10:32 AM, Pavel Bucek<pavel.bucek_at_oracle.com>
>>  wrote:
>>>
>>> It might be a big deal for us though..
>>>
>>> Testcase would be perfect, thanks in advance for it (I want to have this
>>> clarified/fixed before we release 1.7).
>>>
>>> Regards,
>>> Pavel
>>>
>>>
>>> On 5/3/11 2:41 PM, Gary Moore wrote:
>>>>
>>>> Pavel,
>>>>
>>>> Thanks for the reply.  I was just checking to see if anything had
>>>> changed that I missed.  I'm out of the office today but I'll post a
>>>> test case tomorrow.  For now, we just rolled back to the Grizzly 1
>>>> framework so it isn't a big deal.
>>>>
>>>> Thanks,
>>>> Gary
>>>>
>>>> On Tue, May 3, 2011 at 8:04 AM, Pavel Bucek<pavel.bucek_at_oracle.com>
>>>>  wrote:
>>>>>
>>>>> btw, I just found HttpHeadersTest in jersey-apache-client, which uses
>>>>> grizzly2 to start and uses @Provider and passes, so.. I'm not sure what
>>>>> is
>>>>> wrong/can't reproduce.
>>>>>
>>>>> Pavel
>>>>>
>>>>> On 5/3/11 1:46 PM, Pavel Bucek wrote:
>>>>>>
>>>>>> Hello Gary,
>>>>>>
>>>>>> Are you using Jersey test framework or just jersey-grizzly2 module?
>>>>>> Can
>>>>>> you share more details/testcase?
>>>>>>
>>>>>> Thanks,
>>>>>> Pavel
>>>>>>
>>>>>> On 5/2/11 7:39 PM, Gary Moore wrote:
>>>>>>>
>>>>>>> We just moved to Jersey 1.6 this morning.  Jersey is find, and our
>>>>>>> Jersey Test container classes all pass with Grizzly 1.  Grizzly 2,
>>>>>>> however, doesn't pick up any of our MessageBodyWriters/Readers and
>>>>>>> responds to everything with 415 - Unsupported Media Type.  Anyone
>>>>>>> have
>>>>>>> details on how to initialize the Test Grizzly 2 container with our
>>>>>>> Provider classes?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Gary
>>>>>>>
>>>>
>>>
>>
>>
>
>



-- 
Gary Moore
http://www.gmoore.net