Announcement Announcement Module
Collapse
No announcement yet.
Web-FilterMappings causes IllegalStateException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web-FilterMappings causes IllegalStateException

    I'm trying to add an OpenSessionInViewFilter to a SpringDM-based web application to allow lazy loading via Hibernate. I've added the filter mapping to the MANIFEST.MF for the web bundle:

    Code:
    Web-FilterMappings: openSessionInViewFilter;url-patterns:="*.htm"
    And the corresponding bean definition is in META-INF/spring/module-context.xml:

    Code:
    <bean id="openSessionInViewFilter" class="org.springframework.orm.hibernate3.support.OpenSessionInViewFilter" />
    There is no web.xml under WEB-INF.

    Without the filter mapping configured, all pages work fine (albeit with lazy loading issues), but with the filter mapping added when I hit any *.htm page I get:

    Code:
    java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    	org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
    	org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:241)
    	org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:227)
    	org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:171)
    	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
    	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    Am I missing something somewhere?
    Last edited by pumbers; Nov 6th, 2008, 04:25 PM. Reason: Added code tags

  • #2
    The OpenSessionInViewFilter uses a way of retrieving the current WebApplicationContext that doesn't work in the dm Server. It should use the method described here in case of web modules deployed in the dm Server: http://static.springsource.com/proje...cation-context

    For now I think it would be easiest to subclass the OpenSessionInViewFilter and override lookupSessionFactory() to use the method described in the programmer guide. Then use that version instead: you'll have to either obtain the current Bunde Symbolic Name in the code (best, but not sure it's possible) or make it a configurable property set in your xml configuration file.

    Could you please also file a JIRA issue for this (and link to this thread)? At the least we should document cases like this (it also happens when using the JSF integration support, for example) but in the ideal case the development team can come up with some generic solution to allow code that uses the WACU.get[Required]WebApplicationContext methods to simply work when used inside the dm Server.

    Comment


    • #3
      Hi guys,

      FYI: I've updated an existing, related JIRA issue to address this thread as well.

      For further details and to watch the issue, see here: https://issuetracker.springsource.co...e/PLATFORM-173

      Regards,

      Sam

      Comment


      • #4
        FYI: ServerOsgiBundleXmlWebApplicationContext is now stored in the ServletContext under WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT _ATTRIBUTE for web modules.

        Thus, calls to WebApplicationContextUtils.getWebApplicationContex t(ServletContext) and WebApplicationContextUtils.getRequiredWebApplicati onContext(ServletContext) will now return the WebApplicationContext of the current web module for consistency with standard Spring MVC conventions.

        This change will be available in the forthcoming SpringSource dm Server 1.0.1 release.

        Regards,

        Sam

        Comment

        Working...
        X