EJB Inheritance is Different From Java Inheritance

Despite the fact that EJB inheritance sometimes uses Java inheritance – they’re not always the same. Just as you could read in my previous post, EJB doesn’t have to implement any interface to expose a business interface. The other way around is also true – just because EJB is implementing some interface or extending other EJB doesn’t mean it exposes all or any of its views. Let’s say we want to have some basic EJB exposing remote business interface....

March 21, 2013 · 4 min

Communication Between EJB Modules In The Same Application Server

This post describes some of the pitfalls when coping with intercommunication between different modules (EAR, WAR, EJB-JAR) deployed in the same Java EE 6 Application Server. The problem The problem is as follows: you have two modules (let’s take the EARs as an example) that are deployed in the same JVM / Application Server: App1.ear and App2.ear. App1.ear contains: service.jar; it’s an EJB-JAR with the business logic of the application, service-api....

November 17, 2012 · 7 min

Get current JTA transaction status from CMT EJB

You probably know that if you use BMT (Bean Managed Transactions) you can get information about current transaction status by using UserTransaction interface (which implementation can be fetched either by JNDI or using dependency injection) and executing it’s getStatus() method. If you use CMT (Container Managed Transactions) you cannot use UserTransaction interface. Instead, you can manage your transaction through SessionContext interface. This interface gives you two places that hooks to the current transaction: setRollbackOnly(-) and getRollbackOnly()....

September 1, 2011 · 1 min

Properties -- be aware the evil whitespaces!

Just a letter to my future self: When you use Properties and creates the entries, remember to avoid the whitespaces. The properties are inserted as-they-are, so no trimming occurs. It might sound trivial, but it wasted at least an hour of my time, while I was searching for a bug in a totally wrong department… Pure evil: Properties p = new Properties; p.put("java.naming.factory.initial", " org.apache.openejb.client.LocalInitialContextFactory");

May 19, 2011 · 1 min