Announcement Announcement Module
No announcement yet.
Web-FilterMappings causes IllegalStateException Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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:

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

    <bean id="openSessionInViewFilter" class="" />
    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:

    java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    Am I missing something somewhere?
    Last edited by pumbers; Nov 6th, 2008, 05: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:

    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.


    • #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:




      • #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.