Hi Charles,

Sorry for the confusion. This is the way I think the Jersey Servlet is 
working...

1. The resource object constructor is called as if a new resource object is 
created every time a post/get/put is called to the jersey servlet. I was hoping 
it would reuse (reallocate) a jersey servlet and maybe it does and I am 
assuming 
one resource object per jersey servlet.

I was thinking that servlets have to follow a standard as far as model and how 
objects are allocated to the servlet but I am thinking it is based off whatever 
the jersey developers decided to do so I will route this conversation to the 
Jersey team. If they are not pooling resource objects or reusing them that 
would 
explain why Jersey is slower than say Metro. I just happened to run into it 
because of my constructor in my resource object creating a connection to my ejb.

So this is not a Tomcat issue but a Jersey implementation one. I will try a 
workaround to remove my constructor and hope Jersey performs better.

Thanks for trying to help.
-Tony




----- Original Message ----
From: "Caldarale, Charles R" <chuck.caldar...@unisys.com>
To: Tomcat Users List <users@tomcat.apache.org>
Sent: Tue, January 18, 2011 2:52:52 PM
Subject: RE: Jersey Client Call to Tomcat creates new servlet while for Metro 
Soap call it does not do that...

> From: Tony Anecito [mailto:adanec...@yahoo.com] 
> Subject: Re: Jersey Client Call to Tomcat creates new servlet while for Metro 
>Soap call it does not do that...

> I ran some more tests where I added a finalize method and a check 
> in my constructor to see if it was called previosly.
> So far it looks as if the contructor is called only once and the 
> finalize is not called.

Which is a clear indication that your original premise was false.  Tomcat will 
never create more than one instance of a servlet (per webapp), unless you're 
using the SingleThreadModel (a really bad idea, these days); the spec does not 
permit it.

That is my understanding but I do no know what the Jersey servlet is extended 
from as far as single instance per web app.

> Question is does Tomcat call the constructor whenever it realocates
> the servlet? 

What do you mean by "realocates" [sic]?

I was thinking there might be a servlet pool but as you said earlier that is 
not 
possible unless Jersey is setup for more than one servlet.

> does finalized get called for a servlet when tomcat is done with it?

Only when the webapp is undeployed.  You're not really still using a finalize() 
method, are you?
I added a finalize (to the resource object) with a single println statement to 
see if it is called and it was not.

> Maybe I should state the question does 
> "com.sun.jersey.spi.container.servlet.ServletContainer" call the 
> resource class constructor when it is reused?

That's not Tomcat code, so why would you expect anyone on this list to know the 
answer?
I realized that after looking cloesly at the Jersey web.xml.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to