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

Integration testing Spring controllers

Time-constrained projects sometimes mandate crude realism as to the type and extent of test coverage in a software project. You'll find arguments for and against testing in the entire spectrum of opinions from "tests are luxury we can't afford" to "regressions are luxury we can't afford". Constrained or not, there is rarely a good excuse … Continue reading Integration testing Spring controllers