users@jersey.java.net

Re: [Jersey] "Starting Grizzly Framework" on every builder.get() invokation

From: Pavel Bucek <Pavel.Bucek_at_Sun.COM>
Date: Mon, 17 May 2010 14:39:01 +0200

I don't see anything wrong in your code snippet.

Just one think comes to my mind - when do you create that singleton?
Isn't possible you initialize it before every request? (probably not,
I'm only thinking aloud)..

Can you isolate that issue and provide minimal maven based project? I
should be able to find (/solve) your issue when I have reproducible test
case.

Pavel


On 5/17/10 1:29 PM, Martin Scholl wrote:
> Thx for the simple example, I tested it and it worked as expected... In my code the Grizzly initialisation is done in the constructor of a singleton class exactly like in the example:
>
> final String baseURI = "http://" + proxy.getServer().getIP() + ":" + port + "/"; // NOI18N
> final Map<String, String> initParams = new HashMap<String, String>();
> initParams.put("com.sun.jersey.config.property.packages", "de.cismet.cids.server.ws.rest"); // NOI18N
>
> try {
> selector = GrizzlyWebContainerFactory.create(baseURI, initParams);
> } catch (final Exception ex) {
> final String message = "could not create grizzly web container on port: " + port; // NOI18N
> LOG.error(message, ex);
> throw new ServerExitError(message, ex);
> }
>
> Jersey client is most certainly not the issue as the same happens when I invoke methods via browser.
>
> Martin
>
>
> On 17.05.2010, at 12:56, Pavel Bucek wrote:
>
>
>> Container should be initiated after first request as you expect (and it is in my environment). How and when do you start your grizzly instance? And just to cast out jersey client influence - can you make that request for example via browser or curl?
>>
>> I just tested it with our helloworld sample [1], you can do it too. Just unpack, run "mvn compile exec:java" and hit "http://localhost:9998/helloworld". Initialization is done only for first request..
>>
>> Pavel
>>
>> [1] http://download.java.net/maven/2/com/sun/jersey/samples/helloworld/1.3-SNAPSHOT/helloworld-1.3-SNAPSHOT-project.zip
>>
>>
>>
>> On 5/17/10 12:45 PM, Martin Scholl wrote:
>>
>>> Hi Pavel,
>>>
>>> Thanks for you answer.
>>>
>>> I see that client and server are not bound in any way. Yes, I experience this in a Unit Test but I'm not using Jersey test framework. I start up the client and server side implementation and then use the client side impl in these tests (for various reasons). Thus the communication in these tests is done as if it was "real".
>>>
>>> Grizzly reinitialization is done for EVERY get request. I tested this by simply calling the builder.get() method twice from the very same fully initialised WebResource.Builder. I'm really wondering whether I'm doing sth wrong because I would expect the container to be initialised after the first request...
>>>
>>> Cheers,
>>>
>>> Martin
>>>
>>> On 17.05.2010, at 12:01, Pavel Bucek wrote:
>>>
>>>
>>>
>>>> Hello Martin,
>>>>
>>>> client and server side aren't tied in any way, Jersey server doesn't know which client is accessing it, thus restarting after each get is something not related to jersey server or client.
>>>>
>>>> If you experience this in your tests (and you do use jersey test framework) then it is standard behavior BUT grizzly reinitialization happens not after each get() (or request in general) but for each @Test method. Is this your case?
>>>>
>>>> Pavel
>>>>
>>>>
>>>> On 5/17/10 11:45 AM, Martin Scholl wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> I've would like to have a little hint to understand, what is going on when accessing a REST resource using the Jersey Client API and Grizzly Container:
>>>>>
>>>>> Every time I invoke WebResource.Builder.get(MyClass.class) I see the message
>>>>>
>>>>> May 17, 2010 11:34:16 AM com.sun.grizzly.Controller logVersion
>>>>> INFO: Starting Grizzly Framework 1.9.18-i - Mon May 17 11:34:16 CEST 2010
>>>>>
>>>>> which seems to me that Grizzly is initialised every time I invoke the method which would be pretty inefficient.
>>>>>
>>>>> Is this a fact or did I just misconfigure Jersey or Grizzly or both or where did I do sth wrong? Is anyone familiar with this "issue"?
>>>>>
>>>>> Thanks for your help.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Martin
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>