JBoss 4: where do I deploy global filters?

笑着哭i 提交于 2019-12-10 22:09:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!