i have followed docs configure jersey 2.0 springboot.
@component public class jerseyconfig extends resourceconfig { public jerseyconfig() { super(); register(accountresource.class); register(customeraccountresource.class); // register(new clientloggingfilter()); register(new serverloggingfilter()); register(hapiexceptionmapper.class); register(constraintviolationexceptionmapper.class); register(generalexceptionmapper.class); property(serverproperties.bv_send_error_in_response, true); } }
i registering 2 filters,
@component @prematching @priority(integer.min_value) public class serverloggingfilter implements containerrequestfilter, containerresponsefilter{
and
@component public class clientloggingfilter implements clientrequestfilter, clientresponsefilter{
i using jersey server , jersey client in application.
i have configured jersey client bean there 1 instance of it.
@configuration public class xclient { @bean public client client() { return clientbuilder .newbuilder() .sslcontext(sslcontext) .build() .register(new clientloggingfilter()); } }
when autowiring spring managed bean in clientloggingfilter, getting null pointer exception. same bean works fine in serverloggingfilter. hope can me here.
figured out,
@configuration public class xclient { @autowired clientloggingfilter loggingfilter; @bean public client client() { return clientbuilder .newbuilder() .sslcontext(sslcontext) .build() .register(loggingfilter); } }
had autowire filter in configuration class.
Comments
Post a Comment