Dropwizard 0.8 update filter bug

I am upgrading from v0.7.1 to v0.8 and found that the Jersey filter functionality we are using is out of date. Next line:

environment.jersey().getResourceConfig().getContainerRequestFilters().add(new FilterAuthentication());

      

(pretty much identical to the DW manual )

now gives a compiler error:

"The method

getContainerRequestFilters () is undefined for the Type

ResourceConfig"

Please can someone point me in the right direction on how to update this feature. Many thanks

+3


source to share


1 answer


Dropwizard 0.8.x uses Jersey 2.x. Most of the methods have ResourceConfig

changed. For Jersey 2, you can use the register

general purpose method used to bind any JAX-RS component.

Dropwizard also has a method register

bound to jersey()

, so we don't need to call getResourceConfig()

as it jersey().register()

forwards the config register

.

So any of these will work



env.jersey().register(...);

env.jersey().getResourceConfig().register(...);

      

Also see Jersey API 2 ResourceConfig

+3


source







All Articles