How to use the same ContainerRequestFilter for mul

2019-09-02 01:46发布

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条回答
孤傲高冷的网名
2楼-- · 2019-09-02 02:52

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.

查看更多
登录 后发表回答