I am using following code in my controller to display a custom error page in the application:
@GetMapping(path="/error")
public ModelAndView error (Principal principal) {
ModelAndView model = new ModelAndView("error");
model.addObject("userName", principal.getName());
return model;
}
The principal is null when application is deployed as a WAR on stand-alone tomcat. When application is run with embedded tomcat, it works fine.