java.lang.NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapable

My current project is using JPA, heavily. JPA is a spec/standard/interface and I'm using the Hibernate implementation for it, but I import the entities from a different maven module. The entities module has a dependency on JPA, but not on Hibernate. So when I run my unit tests, I suddenly get a: java.lang.NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapable Openjpa? … Continue reading java.lang.NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapable

On JPA identifiers and business keys (or why business keys are a bad idea)

JPA, and for that matter Hibernate, depends on identifying entity instances (I'll refer to them as entities for short) by some key. That key can either be a single property (like a numeric ID column in the corresponding table) or a business key (also referred to as natural key). Business keys are entity properties which … Continue reading On JPA identifiers and business keys (or why business keys are a bad idea)

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

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

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