tags:

views:

28

answers:

1

Hello, i have a web.xml with these 2 servlet:

<servlet>
        <servlet-name>ApplicationContextFactory</servlet-name>
        <servlet-class>com.bamboo.common.factory.ApplicationContextFactory</servlet-class>
        <load-on-startup>1</load-on-startup>
</servlet>

AND

<servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
</servlet>

I need to use these bean declared on the ApplicationContextFactory:

 <bean id="**catalogFacadeTarget**" class="com.bamboo.catW3.business.impl.CatalogFacadeImpl">
        <property name="categoryDAO"><ref local="categoryDAOTarget"/></property>
        <property name="containerDAO"><ref local="containerDAOTarget"/></property>
        <property name="productDAO"><ref local="productDAOTarget"/></property>
        <property name="productOptionDAO"><ref local="productOptionDAOTarget"/></property>
        <property name="productStatusDAO"><ref local="productStatusDAOTarget"/></property>
        <property name="userDAO"><ref local="userDAOTarget"/></property>
</bean>

in the dispatcher-servlet like this:

<bean name="welcome"
    class="com.bamboo.catW3.business.impl.Welcome">
    <property name="successView">
        <value>welcome</value>
    </property>
     <property name="catalogFacadeImpl"><ref   local="**categoryDAOTarget**"/> </property>
</bean>

Is it posible some how? Thank you!

+2  A: 

You can't share contexts between servlets.

If you need to share beans, then you need to move the shared beans out of the ApplicationContextFactory servlet's context and into the root webapp context, using a ContextLoaderListener declared in web.xml. Both servlets will then be able to use the beans defined in that root context.

(I'd give you a link, but springsource.org seems be down at the moment).

skaffman
At least i have a direction thank you! how about that link, springsource.org seems to be up
Ernest