title: Jax-WS 2.2 web service instances management on Glassfish 3
body: <p>I'm studying Jax-WS specification in general and its implementation on Glassfish 3.1.2. I built a simple standard example where a jax-ws soap based web service is called from a jsp page by using the artifacts generated through wsimport (the webservice and the jsp page are both deployed on Glassfish in the same EAR but in 2 different wars).</p>
  
  <p>Everything works as expected but I have a question: looking at the application log, it seems that Glassfish creates a new instance of the webservice each time it is called. I would like to know where Java offically defines how a web container should manage webservice instances and if developers can customize this behaviour.</p>
  
  <p>I read jax-ws 2.1 specification here</p>
  
  <p><a href="http://download.oracle.com/otndocs/jcp/jaxws-2.1-mrel2-eval-oth-JSpec/" rel="nofollow">http://download.oracle.com/otndocs/jcp/jaxws-2.1-mrel2-eval-oth-JSpec/</a></p>
  
  <p>but I found only a clue when speaking about how to publish a webservice using the Endpoint class by hand (section 5.2.2 "Publishing", page 69):</p>
  
  <p>"An endpoint consists of an object that acts as the Web service implementation (called here implementor) plus some configuration information...</p>
  
  <p>An Endpoint will be typically invoked to serve concurrent requests, so its implementor should be written so as to support multiple threads. The synchronized keyword may be used as usual to control access to critical sections of code. For finer control over the threads used to dispatch incoming requests, an application can directly set the executor to be used..."</p>
  
  <p>This note is present even in Jax-WS 2.2 specification (used by Glassfish 3).</p>
  
  <p>Actually, if I build a webservice using only JavaSE 7 (which includes Jax-WS 2.2), this description is true because there is only one instance of the webservice. Is there any reason why JavaEE doesn't follow this policy?</p>
  
  <p>Thanks a lot for your help,</p>
  
  <p>Nico</p>