How to use the same ContainerRequestFilter for multiple projects?

谁说我不能喝 提交于 2019-12-25 03:39:10

问题


I have two projects A and B in which B has dependency on A. So all the classes of A are available to B.

Now, I've defined a ContainerRequestFilter for intercepting some information from request. This is getting invoked if I call the end points of project A. But it's not getting invoked if I call end points of project B.

Obviously, the context roots of project A and project B are different.

Example: http://localhost:8080/projecta/..... http://localhost:8080/projectb/.....

Both the projects are archived in an ear and deployed in same ear.

I actually expected it to work like in the case of @AroundInvoke interceptor.

How to achieve that?

Wildfly 8.0 Resteasy Java EE 7


回答1:


I've added the providers in the web.xml of the second project and it did the work.

    <context-param>
        <param-name>resteasy.providers</param-name>
        <param-value>com.example.SampleRequestFilter,com.example.SampleResponseFilter</param-value>
    </context-param>

For the first project, it's not required. Some how jax-rs is loading the provider. For the second project, I added the above param and it worked.



来源:https://stackoverflow.com/questions/30731511/how-to-use-the-same-containerrequestfilter-for-multiple-projects

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