问题
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
.
回答1:
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.
回答2:
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 .
来源:https://stackoverflow.com/questions/8791644/jboss-4-where-do-i-deploy-global-filters