JBoss: Isolating classloaders for all ears

At the bottom of deployers/ear-deployer-jboss-beans.xml change:

<bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">
      <!-- A flag indicating if ear deployments should have their own scoped
      class loader to isolate their classes from other deployments.
      -->
      <property name="isolated">false</property>
</bean>

to:

<bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">
      <!-- A flag indicating if ear deployments should have their own scoped
      class loader to isolate their classes from other deployments.
      -->
      <property name="isolated">true</property>
</bean>

Singletons with EJB3.0 on JBoss 5.1

To create a singleton bean that can be injected into EJB:
– annotated the class with org.jboss.ejb3.annotation.Service
– let the class implement some Local or Remote interface.

Moreover, when you want to perform some setup upon singleton startup, you can:
– create an *MBean interface with void start()
– make singleton implement the interface
– add @Management([interface class]) annotation on singleton class

Example:

@Local
public interface SingletonExample{}
public interface SingletonExampleMBean {
    void start();
}
@Management(SingletonExampleMBean.class)
@Service
public class SingletonExampleImpl implements SingletonExample, SingletonExampleMBean {
    @Override
    public void start() {
        // some initialization stuff
    }
}

More info can be found in: JBoss reference

Hibernate log4j configuration

To make hibernate log absolutely everything it may log add a following line to log4j configuration:

<logger name="org.hibernate">
   <level value="ALL" />
   <appender-ref ref="FILE"/>
</logger>

FILE should be replaced with the name of the logger you want to use.

E.g. on JBoss the log4j configuration is placed in $JBOSS_HOME/server/[server configuration name]/conf/jboss-log4j.xml