I was hunting down a 400 BAD_REQUEST error in a controller method like:
@RequestMapping(value = "/{schedulerName}/plans", method = RequestMethod.POST, produces = "application/json", consumes = "application/json") @ResponseBody public PlanTemplate createPlanForScheduler(@RequestBody PlanTemplate planTemplate, @PathVariable String schedulerName) { ... } The catch is there was no error written on console. I figured it out at last by setting the root logger to DEBUG level.
15:56:17.528 [1735537490@qtp-2089431280-0] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Returning handler method [public sch.model.PlanTemplate sch.controller.api.SchedulerController.createPlanForScheduler(sch.model.PlanTemplate,java.lang.String)] 15:56:17.529 [1735537490@qtp-2089431280-0] DEBUG o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Reading [class sch.model.PlanTemplate] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@25d08402] 15:56:17.530 [1735537490@qtp-2089431280-0] DEBUG o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolving exception from handler [public sch.model.PlanTemplate sch.controller.api.SchedulerController.createPlanForScheduler(sch.model.PlanTemplate,java.lang.String)]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "schedulerExpression" (class sch.model.PlanTemplate), not marked as ignorable (9 known properties: "name", "waitPrevious", "scheduleExpression", "averageDuration", "status", "parallelLimit", "id", "scheduler", "description"]) As you can see, there is a HttpMessageNotReadableException error thrown, but ExceptionHandlerExceptionResolver sees this as a debugging information. Isn't it a little weird to conceal such an error?
What's the general approach here? I'm thinking of setting org.springframework.web.servlet.mvc to DEBUG, but it stil dumps to much information for my taste.