On coarse- vs. fine-grained synchronization

Performance related topics seem to constantly attract attention and everyone seems to have strong opinions on the matter. Writing code that can be proved [1] to perform according to a certain pattern is probably not the worst place to start with, although the web is full of counterintuitive [2] examples [3] where hardware details weigh … Continue reading On coarse- vs. fine-grained synchronization

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

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' … Continue reading Spring @Value and resolving property names with dots

logging container-managed datasource jdbc with log4jdbc

In my new 'old' project which I just inherited there is - once more - Hibernate and plain JDBC access to a database, happily mixed. Hibernate logs SQL nicely, but that leaves out whatever datbase access the rest of the application is performing. I found log4jdbc very convenient which allows fain-grained logging over every interaction … Continue reading logging container-managed datasource jdbc with log4jdbc

Reddit as an OAuth provider for a Java backend

OAuth (2) and Java work well together, there are plenty of libraries available which handle the general case and the more specific peculiarities of the various OAuth providers. Despite solid implementations like my favourite Spring Social [1] framework  the state of OAuth is at best fragmented. Not only because Spring Social is not as well … Continue reading Reddit as an OAuth provider for a Java backend

JEE6, EJB and Glassfish diaries

Some notes while trying to get up on speed with Glassfish and JEE6, mainly about what can go wrong... and there is plenty of it. The most time-consuming activity is researching generic stack traces which hardly ever point to the real cause. NullPointerException when deploying Been there, done that: A beans.xml in META-INF might cause … Continue reading JEE6, EJB and Glassfish diaries

Solving the 8 Queens puzzle with bit operations

The 8 queens puzzle is a classic (and quite fun to solve) toy problem: place eight queens on a chess board in such a way that all queens could fully move without being obstructed by any other queen. While without practical applications, it illustrates a number of aspects of designing algorithms and implementing programmes: - … Continue reading Solving the 8 Queens puzzle with bit operations

The jsp-file directive

The jsp-file directive in web.xml allows mapping of JSPs to concrete URLs: <servlet> <servlet-name>My Hidden Page</servlet-name> <jsp-file>/mydir/foo.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>My Hidden Page</servlet-name> <url-pattern>/hidden</url-pattern> </servlet-mapping> Shame on me, I didn't know about this. As seen here: http://mail-archives.apache.org/mod_mbox/tomcat-users/200107.mbox/%3CPine.BSF.4.21.0107271807540.7976-100000@localhost%3E

A better eq() when matching method arguments with Mockito

I learned late of Mockito [1], even so more I love it. Walking a little farther away from the basics, a frequent needs presents itself to match method parameters (either when specifying or verifying behaviour) based on properties of complex objects which do not implement the java equals contract. Such an example would be verifying … Continue reading A better eq() when matching method arguments with Mockito