Debugging Spring REST bad request 400 codes

This happens way too often: you POST or PUT something to a Spring @RestController and Spring only tells you that there is a bad request, HTTP 400 code; no further explanations, no logs, no exceptions.

Spring logs the error cause under the category “org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod"
so you can enable logging for that in your log4j.properties:

log4j.logger.org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod=DEBUG,stdout

[1] Debugging “HTTP 400” errors in Spring annotated MVC controllers
http://fastpicket.com/blog/2012/05/19/debugging-http-400-errors-in-spring-annotated-mvc-controllers/

One thought on “Debugging Spring REST bad request 400 codes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s