Reputation: 11835
I use java, spring-ws and have a web service.
Every time I run make a new request to my web service I want that everything resets and all variables are fresh and null. So I added "scope=request" to my web service's application-context.xml but I still have the variable values(even not static vars) kept from my previous request.
My web service(as a jar file) is being used as a plugin from another main web project. and I gave reference to my web service from the main web project's web.xml file like this;
<servlet>
<servlet-name>mws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/resources/webservice/applicationContext-WebService.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
Also in this web.xml I define another dispatcher servlet for the main project, is that possible that it creates 2 spring containers and they interfere?
this is how I define scope in the web service's appcontext.xml file:
<bean id="infService" class="com.ws.im.InfService" scope="request">
<property name="webServiceConfiguration" ref="wsConfiguration" />
<property name="properties">
<bean class="com.ws.PropertyResource">
<property name="resource" value="/WEB-INF/clientspecific/Inf.properties" />
</bean>
</property>
</bean>
So I guess everytime I run my main web project it loads once in the beginning my web service's app context.xml file and no matter I change its scope it does not work cause the main project defines the scope? Can I define the scope of a servlet above? or this idea is totally wrong and I did something wrong in my web service configuration xml's?
thanks
Upvotes: 2
Views: 1895
Reputation: 32397
I think you might have gone wrong somewhere else because your config looks fine.
Can you add some code into the constructor of com.ws.im.InfService
:
java.util.logging.Logger.getAnonymousLogger().info(
"Instantiated, identity [" + System.identityHashCode(this) +"]");
This should print a different identity string for each request, if the request scoping is working correctly.
Edit:
Needed to add <aop:scoped-proxy/>
to bean definition
Upvotes: 3