Search code examples
javaspringmavenservlet-filtersweb-fragment

Web fragments with maven


I've just discovered web fragments and I'd like to use them in my pluggable application. Basically I'm building a plugin which will contain the security part of my app (based on Spring security). The web fragment contains only the servlet filter:

<!-- Loads the security fragment first -->
<ordering>
    <before>
        <others />
    </before>
</ordering>

<!-- Spring security filter -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

The problem is that it's not working at all. The filter works fine if I test it in the main app but if I put it here I'm not intercepting any call. I think it may be caused by the maven build. I'm packaging the project as a jar because I've read around to do so. The web-fragment.xml is under /bin/META-INF/.

Can anyone explain me what I'm doing wrong?

Thank you.


Solution

  • Place your web-fragment in src\main\resources\META-INF\web-fragment.xml