Announcement Announcement Module
Collapse
No announcement yet.
Web Modules: init()-method of filters not called? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web Modules: init()-method of filters not called?

    Hi all

    Is it the case that the init()-method of ServletFilters is not called when I declare the filter in the MANIFEST.MF Instead in the web.xml? If yes, isn't this i very critital bug or is this "as designed"?
    Most of JSF Component Libraries depend on a call to "init()".

    Regards
    Michael

  • #2
    Web Modules: init()-method of filters not called?

    Hi Michael,

    Your assumption is correct: if you configure a Sevlet Filter as a bean in your web module's application context and then delegate to that bean via Spring's DelegatingFilterProxy, then yes, the init() method of your Filter will not be called.

    FYI: using Web-FilterMappings in MANIFEST.MF configures a DelegatingFilterProxy automatically for you, but the 'targetFilterLifecycle' property is not set. Thus the configured DelegatingFilterProxy will not delegate calls to init() to the underlying Filter bean.

    A viable solution to this is to use web.xml fragments in your web module. A web.xml fragment is a standard web.xml deployment descriptor that you use to configure your web application as you normally would. The S2AP will then merge configuration generated via Web-* manifest headers into the web.xml fragment you provide. This gives you the flexibility to use all standard web.xml elements, and the Platform will then augment your configuration with a preconfigured DispatcherServlet, DelegatingFilterProxy, etc.

    Thus, if you need to manually configure a Filter, using a web.xml fragment gives you the freedom to do so!

    Regards,

    Sam

    Comment


    • #3
      Web Modules: init()-method of filters not called?

      Hi Michael,

      > If yes, isn't this i very critital bug or is this "as designed"?

      It isn't essentially critical, since (as of beta5) you can use web.xml fragments to meet your needs. In addition, a Shared Services WAR would not suffer from this, since Shared Services WARs do not use Web-* manifest headers.

      You do, however, bring up a good point with regard to web modules. Thus, I've created a JIRA to track this here:

      https://issuetracker.springsource.com/browse/PLATFORM-60

      Cheers,

      Sam

      Comment


      • #4
        Web Modules: init()-method of filters not called?

        I have the same issue here.
        I want to load the Tapestry5 web filter and finally found out that the source of the problem is that the init() method is not called.
        I will try with the web.wml fragment solution but it should work since it is the normal way

        Comment


        • #5
          Web Modules: init()-method of filters not called?

          Hi guys,

          Please note that I have coded a fix for this which will be included in the beta6 release. For details, consult the JIRA issue:

          https://issuetracker.springsource.com/browse/PLATFORM-60

          Regards,

          Sam

          Comment

          Working...
          X