JBoss 4: where do I deploy global filters?

3.6k views Asked by At

I want to use "global" HTTP filters.

Therefor, I edited deploy/jboss-web.deployer/conf/web.xml and added:

<filter>
    <filter-name>StatisticsFilterHitCount</filter-name>
    <filter-class>myapp.StatisticsFilterHitCount</filter-class>
</filter>

<filter-mapping>
    <filter-name>StatisticsFilterHitCount</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Now, when I start the server, not a single artifact can be deployed. A huge exception is logged on each deployment attempt. Sorry, can't paste it here. I suppose, at the time of deployment, the filter class is not present yet.

So, where (and how) do I have to deploy such filter globally?

Currently, it's in applications/5apps, the packaging is .war.

2

There are 2 answers

2
Vadzim On BEST ANSWER

Look at Jboss/server/default/deploy/jboss-web.deployer/conf/web.xml. There is even an example of global CommonHeadersFilter.

But you would have to place the code in some jar under JBoss/server/default/lib. JBoss can't peek up the code in the war at web container's initialization process.

1
Aravind A On

If the class file is missing , just build it in . There should be a class with the name StatisticsFilterHitCount inside the war under myapp package which implements the Filter interface , overrides

           doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException 

           init(FilterConfig filterConfig)

           public void destroy()

and does whatever it is meant to do . Check for this .