Ok I’m using Apache Axis2 and Spring Framework. Basically The WebServiceHandler class is the one that exposed all the web service operations. So when a request comes in, this is the class that gets called.
My understanding is that for every request, Tomcat or Axis2 should create a new Thread. But doing a “Thread.currentThread().getId()” and “Thread.currentThread().getName()” always have same id and name.
This I believe causes problems on my DAO since I’m using Hibernate to create 3 SessionFactories and using the current thread model to execute queries, which makes whole system really slow.
I could spawn a new Thread for every operation before calling my DAO class but haven’t tried that yet. Any way to solve this through configuration in Axis2 or Spring? Thanks.
Part of my applicationContext.xml below:
<!-- Axis2 Web Service, but to Spring, its just another bean that has dependencies -->
<bean id="springContext" class="com.ws.beans.spring.SpringContext"/>
<bean id="springAwareService" class="com.ws.beans.WebServiceHandler" >
<constructor-arg ref="springContext" />
</bean>
This is handled by tomcat (or any web container). It doesn’t spawn a new thread for every request – but instead uses a thread pool to execute the incoming request. In your case since you are only executing one request at a time – the same thread is being used to execute subsequent requests. If you try executing many requests in parallel – then you will notice that the thread ids / names will be different.