When i run the first petittion of a bean's method (let's say method A) on the server everything seems ok, but when running for the second time any petition on this carrierRESTWS bean (let's say method B), the dao being used is the same carrierDAO instance. How can i avoid having this problem and making the injection use a new instance of the dao each time this carrierRESTWS bean is being called?
Beans configuration inside xml file:
<bean id="carrierRESTWS" class="ar.com.anovo.controllers.rest.CarrierRESTWS">
<property name="carrierDAO" ref="carrierDAO"/>
</bean>
<bean id="carrierDAO" class="ar.com.anovo.dao.CarrierDAO"></bean>
Set the scope of "carrierDAO" to "prototype":
<bean id="carrierDAO" class="ar.com.anovo.dao.CarrierDAO" scope="prototype" />
This will create a new instance, once an injection is required.
More about scopes can be found in the Spring Doc.