I have a Resteasy application that uses Spring and contains ContainerRequestFilter
and ContainerResponseFilter
implementations annotated with @Provider
. The application is using version 3.0-beta-6
of Resteasy.
These filters work as expected when they are added to the resteasy.providers
context parameter in web.xml like so:
<context-param>
<param-name>resteasy.providers</param-name>
<param-value>foo.filter.LoggingRequestFilter,
foo.filter.LoggingResponseFilter</paramvalue>
</context-param>
If I remove the filters from here they are no longer called.
I was assuming that these providers would automatically register with Resteasy when using org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
. The strange thing to me is that it worked for PreProcessInterceptor
implementations in previous versions of Resteasy, and still works in v3, but Filters and ExceptionMappers do not auto-register.
resteasy.providers
context parameter necessary if the classes are annotated with @Provider
and scanned by Spring?In order to get the providers scanned by Spring I had to add the includeFilters
parameter to @ComponentScan
on my Spring Java configuration class.
@ComponentScan(value = "com.foo",
includeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, value = Provider.class))
You can also just annotate them with @Component
along with @Provider
and Spring will make sure they get detected by Resteasy when using Resteasy's SpringContextLoaderListener
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With