Category: spring

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 … 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;DRHibernate'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 databaseThis one annoyed me plenty and took a great deal of debugging to sort out.The settingMy spring application … 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 applicationWhile 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 Aspirin to … Continue reading Tomcat, Spring and memory leaks when undeploying or redeploying an web application

Spring @Value and resolving property names with dots

I'm moving a legacy application (I seem to be doing that a lot recently) to Spring and injecting properties with @Value into Spring managed beans all over the place. And it doesn't work:public class SomeService{ @Value("#{the.org.namespace.someProperty}") private String someProperty;}Dots have apparently a special meaning, so this fails with a message that 'the' can't be found:EL1008E:(pos … Continue reading Spring @Value and resolving property names with dots

Speeding up development by splitting a webapp into parts

I love tagfiles: they feature a well known syntax (EL from JSP), they allow for reusable UI components, they are well supported by my favourite IDE and, most importantly, modifications are instantly visible because the servlet container does not have to restart.At least in theory, because reality often looks different: after a few edits tomcat … Continue reading Speeding up development by splitting a webapp into parts

Liferay diaries: Help! My validation errors are not showing!

While still battling form submissions in my Liferay/Spring MVC Form controller/Multi-portlet beast, I noticed that the Spring form tags would not display errors. As this post [1] explains, the reason is that the form backing object must be named exactly as the class consituting the backing object, but with the first letter in lowercase.Thus the … Continue reading Liferay diaries: Help! My validation errors are not showing!

Liferay diaries: Multiple spring form controllers in a portlet

Now there comes a moment in the life of every portlet author, be it a seasoned veteran (like jstam) or a fresh starter like myself when you need to do implement something out of the ordinary for which portlets were not intended. Last week we had to scetch up an all-in-one portlet that could display … Continue reading Liferay diaries: Multiple spring form controllers in a portlet