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 … Continue reading Debugging Spring REST bad request 400 codes

Spring MVC REST controller says 406 when emails are part URL path

You've got this Spring @RestController and mapped a URL that contains an email as part of the URL path. You cunningly worked around the dot truncation issue [1] and you are ready to roll. And suddenly, on some URLs, Spring will return a 406 [2] which says that the browser requested a certain content type … Continue reading Spring MVC REST controller says 406 when emails are part URL path

LocalContainerEntityManagerFactoryBean, Hibernate and superflous tables created in wrong database

TL;DR Hibernate's (3.2-3.4) JPA implementation will pick up hbm files on it's own when it should be looking only at persistence.xml, thus: - loading more entities that it should - loading the wrong entities - performing schema updates in the wrong database This one annoyed me plenty and took a great deal of debugging to … Continue reading LocalContainerEntityManagerFactoryBean, Hibernate and superflous tables created in wrong database

Tomcat, Spring and memory leaks when undeploying or redeploying an web application

In this post I'll talk about a new kind of memory leak in Spring applications involving transaction management and initializing beans. About memory leaks when undeploying a web application While developing a web application with Spring and Tomcat I frequently run out of heap space. The web is full of stories about this. There is … Continue reading Tomcat, Spring and memory leaks when undeploying or redeploying an web application