Thursday, December 22, 2005

JUnit: Loader constraints violated

I was running my JUnit tests via Maven, and ran into the following error:

loader constraints violated when linking org/w3c/dom/Node class
java.lang.LinkageError: loader constraints violated when linking org/w3c/dom/Node class at...

The solution: set maven.junit.fork=true in your project.properties file.

XDoclet (EJB) and Spring

My project was using XDoclet to annotate our EJBs. I wanted to use Spring, and still keep the EJB, so I had the bean class extend Spring's AbstractStatelessSessionBean. The problem? The classes that XDoclet generated extended AbstractStatelessSessionRemote, AbstractStatelessSessionLocal, etc., all of which, don't exist.

The solution? Quite simple... by using the @ejb.home and @ejb.interface attributes, you can override the default behavior and specify which interface(s) the home interface and component interface should extend.

Example:
@ejb.home
extends="javax.ejb.EJBHome"
local-extends="javax.ejb.EJBLocalHome"