1

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.

Aurasphere
  • 3,841
  • 12
  • 44
  • 71
  • web-fragment must be located in `META-INF`, not `/bin/META-INF` – michaldo May 10 '16 at 12:38
  • @michaldo Under project root? I've just tried and it's still not working. – Aurasphere May 10 '16 at 12:40
  • Your project is JAR, so your output is JAR. Check your output file and find where web-fragment is located. – michaldo May 10 '16 at 12:57
  • You are right. There's no web-fragment in the output file. It seems that maven puts it there only with the war packaging. The problem is that I can't do that since there's no web.xml... – Aurasphere May 10 '16 at 13:06
  • You are wrong. I have maven, Jar project, web-fragment and all works. My fragment is located in `src\main\resources\META-INF\web-fragment.xml` – michaldo May 10 '16 at 13:08
  • I was indeed wrong. Now it's working fine. If you want to write an answer I'll accept it. Thank you. – Aurasphere May 10 '16 at 13:11

1 Answers1

5

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

michaldo
  • 4,195
  • 1
  • 39
  • 65