users@jersey.java.net

Re: [Jersey] embedding jersey inside GrizzlyWebServer

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 28 Apr 2009 12:48:43 +0200

On Apr 28, 2009, at 12:32 PM, Zoltan Arnold NAGY wrote:

> Paul Sandoz wrote:
>>
>> The problem is specific to the way the the initialization parameter
>> is set.
>>
>> You need to call:
>>
>> jerseyAdapter.addInitParameter("javax.ws.rs.Application",
>> JerseyAdaptor.class.getName());
> you're right, I missed the part where I had to use addInitParameter
> instead of setParameter :)
>
> but still no luck, it's not working.
>
> first I tried to whip up a simple, one-file example, but apperently,
> the packages must be public
> in order to work this way
>

Use inner public static classes and it should work fine.


> (else I'd get Caused by: java.lang.IllegalAccessException:
> Class com.sun.jersey.spi.container.servlet.WebComponent can not
> access a member of class JerseyAdaptor with modifiers "",
> which is okay from the stacktrace, as the container is in an other
> package, so cant see mine.)
>
> so I split them up. Here's the complete code: http://nagyz.pastebin.com/m5d97e7db
>
> I get a 404 when I try to access it, so it seems Jersey hasnt
> discovered my resource.
>

What is the URI you are using?

   http://localhost:7000/jersey/helloworld

?

I have not tried using Jersey with the following:

    ws.addGrizzlyAdapter(jerseyAdapter, new String[] { "/jersey" });

The Jersey ServletContainer needs to know the correct base URI that
the resource classes are deployed at and i am wondering if this is an
issue.

You might want to try the following instead:

             adapter.setContextPath("/jersey");


Generally when using Grizzly i tend to use the Jersey/Grizzly factory
mechanisms, if i do not require any additional Grizzly configuration:

https://jersey.dev.java.net/nonav/apidocs/1.0.3/jersey/com/sun/jersey/api/container/grizzly/GrizzlyWebContainerFactory.html
Paul.

> Any ideas would be greatly appreciated! Sorry for being such a noob,
> I just started using jersey. :)
>


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