i’m unable to inject a spring session bean in my custom success handler:
@Component
public class CustomSavedRequestAwareAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
@Resource
private SessionController sessionController;
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
super.onAuthenticationSuccess(request, response, authentication);
sessionController.setUtenteOnline();
}
that return a null pointer exception on sessionController.
Thank you in advance
Your success handler is probably a singleton so you can only inject singletons into it reliably. You can solve this problem using scoped dependencies. Basically, it involves Spring injecting a singleton dynamic proxy that manages fetching the real bean from session scope and delegating calls to it.