This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Web Services and the fly likes How many instances of web service class are created? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "How many instances of web service class are created?" Watch "How many instances of web service class are created?" New topic
Author

How many instances of web service class are created?

Dean Fredericks
Ranch Hand

Joined: Dec 04, 2004
Posts: 60
I have a java bean web service.

I place to class into axis and rename it to a .jws, and there is my web service.

When I look at my log files - it seems the contructor of my class is running for every request that is comming in!

That cant be right !? thats not how servlets works! I want only one instance of my class to be made, otherwise I think it will mess up my connection pooling. My DataSource is looked up in the constructor - I want one dataSource - many connections. Not each request getting its own istance of the class and therefore its own datasource!


PLEASE WATCH THIS VIDEO: <a href="http://www.glumbert.com/media/dolphin" target="_blank" rel="nofollow">http://www.glumbert.com/media/dolphin</a><br /> <br /><-- that video is no joke. Spread the word... this cant go on!!!<br /> <br />SCJP 1.4, SCBCD 1.3, SCWCD 1.4, SCMAD 1.0
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8876

Are you using Axis ? If yes it is possible to create a single instance of WS class. I have posted a link before in this forum so searching the forum will help.


Groovy
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35249
    
    7
thats not how servlets works!

Why would you expect it to work like a servlet? Like you said, it's a bean that gets exposed as web service. The Axis documentation does not mention anywhere what the lifecycle semantics are, but it does mention the various drawbacks the .jws approach has, which make it unsuitable for serious use.
[ September 30, 2005: Message edited by: Ulf Dittmer ]

Android appsImageJ pluginsJava web charts
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
As DataSource is thread safe and as only one is needed, declare it static.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8876

Originally posted by Ulf Dittmer:

Why would you expect it to work like a servlet? Like you said, it's a bean that gets exposed as web service. The Axis documentation does not mention anywhere what the lifecycle semantics are, but it does mention the various drawbacks the .jws approach has, which make it unsuitable for serious use.

[ September 30, 2005: Message edited by: Ulf Dittmer ]


I think he wanted only one instance of the service class same as the servlet.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How many instances of web service class are created?
 
Similar Threads
Hot Deploy DataSource in Tomcat?
Book: High-assurance design for Web services ?
database-access JavaBean - thread safety
Spring + JPA + Hibernate and multiple Database connection
calling web service from another web service logging