For a Java EE application I created a custom javax.ws.rs.container.ContainerRequestFilter
as kindly documented by Abhishek. It basically is running fine. However, when I move the annotation and filter (e.g. from com.foo.resources
) to another package on the same level (e.g. com.foo.filters
) then the filter is not applied anymore. Why not?
It does work if the filter and annotation are moved to a sub-package (e.g. from com.foo.resources.filters
).
Sounds like you are using some package scanning for your application configuration, and you have com.foo.resources
listed as the package to scan. With this package and all sub-packages recursively for all your @Path
and @Provider
classes, then register them. If you want to use multiple packages then you should be able to list both of them, delimited by a comma. I would suggest instead to just use com.foo
, the common parent package, as it will scan the package recursively.