You are here

Java EE advanced topic, shortcomings, troubles, tricks

Here is a list of issues I came across when working with Java EE (J2EE).

Limit number of EJB3 MDB instances (JBoss 4.0.5.GA)

First of all, do not fall into a trap (as me) and do not follow JBoss MDB Config WiKi, it is related to EJB 2.x. The <configuration-name> is ignored by org.jboss.ejb3.ddJBossDDObjectFactory (called from org.jboss.ejb3.Ejb3HandlerFactory.DDFactory(Ejb3Deployment di))

Use the ActivationConfigProperty "maxSession", default is 30:

@MessageDriven(activationConfig = {
		propertyName = "destinationType",
		propertyValue = "javax.jms.Queue"),
		propertyName = "destination",
		propertyValue = "queue/email"),
		propertyName = "maxSession",
		propertyValue = "1")})
public class MailerMDB implements MessageListener {


  • DLQ - Dead Letter Queue (poison message queue)
  • JBossMQ - Java Message Service API implementation by JBoss
  • ConfigJMSMessageListener - Configuration of JMS message Listener, can be used in ActivationConfigProperty annotations

JBoss EJB3/Hibernate doesn't escape table or column names (JBoss 4.0.5.GA)

The following code may cause troubles to SQL engine, because the table name or column name clashes with SQL keyword.

@Entity // PostgreSQL doesn't like "create table User ..."
public class User implements Serializable {
// HSQL doesn't like "order" in SQL query
public byte getOrder() {

There is no portable solution, the following code may not work, it depend on database provider. Isn't this case for database abstraction?

@Table(name="\"User\"") // PostgreSQL OK, HSQL bug
public class User implements Serializable {
@Column(name="`order`")// PostgreSQL bug, HSQL OK
public byte getOrder() {

JBoss and HSQL (JBoss 4.0.5.GA)

JBoss 4.0.5.GA is distributeds with HSQL database. Unfortunately the shipped version is quite old (which version?) and has many bugs. The HSQL 1.8.x works fine with JBoss, must place the jar in server/default/lib folder.

The HSQL is tiny SQL engine written in pure Java and it has severe limitations and default settings, that may not be good for your application testing. For instance, prior to 1.7.2, all table column type definitions with a column size, precision or scale qualifier were accepted and ignored. The 1.7.2 default settings still ignores sizes.

Connection URL with enforced size property

For in memory database:
For hsql database in JBoss the hsqldb-ds.xml must be changed (specifying property in connection string doesn't work). It is a hack but should work, see As an alternative, use <new-connection-sql>:
<mbean code="org.jboss.jdbc.HypersonicDatabase" 
<attribute name="Database">default;sql.enforce_strict_size=true&lt/attribute>


Tomcat 5 logging

I have always troubles to setup tomcat (conatiner) logging correctly. The default installation of Tomcat 5.0.28 on Gentoo doesn't log, catalina.out says:

log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.Embedded).
log4j:WARN Please initialize the log4j system properly.		

Here is a checklist for succesfull logging:

  • Place commons-logging.jar to {tomcat}/common/lib folder
  • Place log4j.jar to {tomcat}/common/lib folder
  • Place (or log4j.xml) to {tomcat}/common/classes folder
  • Add the {tomcat}/common/classes folder to classpath in {tomcat}/bin/
  • (optionally) Add -Dlog4j.debug=true to {tomcat}/bin/, this will show debug messages from log4j startup.