Hi,
I've been trying to follow the Pro-Spring example on javaWorld, example in Rod's book and discussions on this list to connect to remote EJB's but all seems to be falling down at the JNDI lookup.
I'm using Jboss 4.01 with Spring 1.2.1.
I have three examples here but only one works. The old fashioned lookup job. The other two via Spring continue to give BeanCreation exceptions that the Object cannot be found, yet the jndi name is correct. I'm probably doing something wrong but can't figure out what at the moment.
Here are the definitions in the applicationContext file
<bean id="jndiJBoss" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfac es.NamingContextFactory</prop>
<prop key="java.naming.provider.url">jnp://localhost:1099</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.namin g:org.jnp.interfaces</prop>
</props>
</property>
</bean>
<bean id="adminServiceHome" class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiTemplate"><ref bean="jndiJBoss"/>
</property>
<property name="jndiName">
<value>ejb/adminService</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
</bean>
<bean id="adminService"
class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">
<property name="jndiTemplate"><ref bean="jndiJBoss"/>
</property>
<property name="jndiName">
<value>ejb/adminService</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
<property name="businessInterface">
<value>
nl.anwb.anwbnl.services.generic.admin.AdminService
</value>
</property>
</bean>
The ejb/jboss files
<session>
<display-name>AdminService</display-name>
<ejb-name>AdminService</ejb-name>
<home>
nl.anwb.anwbnl.ejb.generic.admin.AdminServiceRemot eHome
</home>
<remote>
nl.anwb.anwbnl.ejb.generic.admin.AdminServiceRemot e
</remote>
<local-home>
nl.anwb.anwbnl.ejb.generic.admin.AdminServiceLocal Home
</local-home>
<local>
nl.anwb.anwbnl.ejb.generic.admin.AdminServiceLocal
</local>
<ejb-class>
nl.anwb.anwbnl.ejb.generic.admin.AdminServiceBean
</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<env-entry>
<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>
applicationContext.xml
</env-entry-value>
</env-entry>
</session>
<session>
<ejb-name>AdminService</ejb-name>
<jndi-name>ejb/adminService</jndi-name>
</session>
This code works, but via Spring doesn't seem to :-(
Properties props = System.getProperties();
props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
Context ctx = new InitialContext(props);
Object obj = ctx.lookup("ejb/adminService");
What's strange is that adding the JNDI ref to the proxy doesn't seem to make much difference. So perhaps I'm setting that incorrectly?
Colin


Reply With Quote