You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tony Anecito <ad...@yahoo.com> on 2011/01/17 04:19:03 UTC

Jersey Client Call to Tomcat creates new servlet while for Metro Soap call it does not do that...

Hi All,

I noticed with Jersey 1.5 that whenever I execute a Jersey client side request 
it creates a new servlet rather than reuse the existing servlet. I know this 
because in my constructor for my servlet I send out a message and it is going to 
the Tomcat command console.
In my Web.xml I have a tag for at startup create 3 servlets.
This does not happen with my Metro based Servlets. Tomcat resuses those 
servlets.

Any ideas what might cause this? If I ran a load test Tomcat using Jersey might 
not scale very well.

Thanks,
-Tony


      

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


RE: Jersey Client Call to Tomcat creates new servlet while for Metro Soap call it does not do that...

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tony Anecito [mailto:adanecito@yahoo.com] 
> Subject: Re: Jersey Client Call to Tomcat creates new servlet while for Metro Soap call it does not do that...

> I was thinking that servlets have to follow a standard

They do - the servlet spec.

> how objects are allocated to the servlet

That phrase makes no sense to me.

> So this is not a Tomcat issue but a Jersey implementation one.

Definitely.  Tomcat has no concept of "resource object" (at least as you seem to be using the term).  If it's not in the servlet spec or the Tomcat's documented extensions thereto, Tomcat has no knowledge of or control over it.

 - 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Jersey Client Call to Tomcat creates new servlet while for Metro Soap call it does not do that...

Posted by Tony Anecito <ad...@yahoo.com>.
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" <Ch...@unisys.com>
To: Tomcat Users List <us...@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:adanecito@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


      

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


RE: Jersey Client Call to Tomcat creates new servlet while for Metro Soap call it does not do that...

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tony Anecito [mailto:adanecito@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.

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

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

> 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?

> 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?

 - 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Jersey Client Call to Tomcat creates new servlet while for Metro Soap call it does not do that...

Posted by Tony Anecito <ad...@yahoo.com>.
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.

Question is does Tomcat call the constructor whenever it realocates the servlet? 
Also, does finalized get called for a servlet when tomcat is done with it?

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

Regards,
-Tony



----- Original Message ----
From: Tony Anecito <ad...@yahoo.com>
To: Tomcat Users Group <us...@tomcat.apache.org>
Sent: Sun, January 16, 2011 8:19:03 PM
Subject: Jersey Client Call to Tomcat creates new servlet while for Metro Soap 
call it does not do that...

Hi All,

I noticed with Jersey 1.5 that whenever I execute a Jersey client side request 
it creates a new servlet rather than reuse the existing servlet. I know this 
because in my constructor for my servlet I send out a message and it is going to 

the Tomcat command console.
In my Web.xml I have a tag for at startup create 3 servlets.
This does not happen with my Metro based Servlets. Tomcat resuses those 
servlets.

Any ideas what might cause this? If I ran a load test Tomcat using Jersey might 
not scale very well.

Thanks,
-Tony




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


      

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