Resources in Spring/Restlet project instantiated twice per request

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Resources in Spring/Restlet project instantiated twice per request

gavin hackeling

I have a Spring 3.1/Restlet 2.0 web application. I see that the beans for my resources are instantiated twice per request. I suspect that this is because an instance is created for both the root and servlet contexts, but I can't figure out how to either merge the contexts or only instantiate the beans only in the servlet's context.

Any help would be appreciate. I have include what I believe are the relevant snippets below.


My web.xml contains the following:



integrationApi-servlet.xml contains the following:

<!-- Scan the package for classes to inject -->
<context:component-scan base-package="" />

<!-- Setup the main component -->
<bean id="integrationApiComponent" class="org.restlet.ext.spring.SpringComponent">
<property name="defaultTarget" ref="integrationApiAppliction" />

<!-- Setup the router -->
<bean id="integrationApiAppliction" name="root"
<property name="root" ref="router" />

<!-- Define the router -->
<bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" />

<!-- Routes and resources -->
<bean name="/v1/foo/{val}"
scope="prototype" autowire="byName" />
<bean name="/v1/status"
scope="prototype" autowire="byName" />

<!-- Load the properties -->
<!-- Camel Endpoints -->
<!-- Configure the ActiveMQ component -->
<!-- Services -->