This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
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: 8904

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: 41180
    
  45
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 ]

Ping & DNS - my free Android networking tools app
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: 8904

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://aspose.com/file-tools
 
subject: How many instances of web service class are created?
 
Similar Threads
Hot Deploy DataSource in Tomcat?
calling web service from another web service logging
database-access JavaBean - thread safety
Spring + JPA + Hibernate and multiple Database connection
Book: High-assurance design for Web services ?