Using remote EJBs in spring beans

To inject a reference to remote session bean into application context put the following lines into your application context definition:

 <bean id="someBean" lazy-init="true"
    <property name="jndiName" value="/DictionaryFacade" />
    <property name="businessInterface" value="com.programmingnotepad.EJBInterface" />
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="refreshHomeOnConnectFailure" value="true" />
    <property name="lookupHomeOnStartup" value="false" />

    <bean id="jndiTemplate">
        <property name="environment">
                <prop key="java.naming.provider.url">localhost:1099</prop>
                <prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>
                <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>

Then you can inject your bean simply using Autowired:

public class SomeSpringBean {
    private EJBInterface;

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


public interface SingletonExample{}
public interface SingletonExampleMBean {
    void start();
public class SingletonExampleImpl implements SingletonExample, SingletonExampleMBean {
    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"/>

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


Separating JBoss clusters

-u 233.3.4.[some number]

More info can be found in JBoss documentation:
JGroups isolation


Build specified module with dependencies in Maven

Because I always forget how to do it:

mvn clean install -pl <comma separated module list> -am

From maven help:

 -am,--also-make                        If project list is specified, also
                                        build projects required by the
 -pl,--projects                    Comma-delimited list of specified
                                        reactor projects to build instead
                                        of all projects. A project can be
                                        specified by [groupId]:artifactId
                                        or by its relative path.