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;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s