Announcement Announcement Module
Collapse
No announcement yet.
Application Contexts Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Application Contexts

    Hi All,
    I'm a newbie here. I have what I hope is a fairly straightforward question about application contexts.

    It appears that my application has two application contexts - the root context which is created by the ContextLoaderListener, and a child context which is created by my action servlet (I'm using struts 1.2.9). The struts servlet is integrated with Spring using Spring's DelegatingRequestProcessor. The child context appears to be an exact copy of the root context.

    So I have two questions:
    1. Why does the servlet need a copy of the root context? Can it not use the root context directly?

    2. How do I change it to use the root context? I need to do this because I'm using the hibernate OpenSessionInViewFilter. Since there are two contexts, the filter ends up being intialized with a different sessionFactory from the daos that the action servlet uses. Thus the OSIV filter doesn't work.

    I assume if I were using Spring MVC, the dispatcher servlet would also have this problem?

    Thanks in advance,
    Owen

    ps. I'm using Spring 2.08 and Tomcat 5.5 (which uses servlet api 2.4 - I think). I can post the code here if necessary.

  • #2
    Don't load the same xml files...

    1. Why does the servlet need a copy of the root context? Can it not use the root context directly?
    It doesn't copy the context, it uses the context. However if you tell it to load the same xml file it basically ends up as a copy.

    I suggest the javadocs
    Last edited by Marten Deinum; Feb 10th, 2011, 04:56 AM.

    Comment


    • #3
      Ah ok, my bad. I'm not so familar with Struts and have just started a new job where I don't know the code base. I didn't see the code:
      Code:
      	<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
      		<set-property property="contextConfigLocation" value="/WEB-INF/appContext.xml" />
      	</plug-in>
      Which was in amongst the mountains of config I'm wading through at the moment. I've removed this and all is good now.

      Thanks very much for your help!

      There doesn't appear to be a user rating system on here, otherwise I'd mark you up
      Last edited by linzello; Feb 10th, 2011, 07:12 AM.

      Comment

      Working...
      X