Hi
I am using JNDI template to look up EJB.
My ejb-jar.xml is as follows
<session >
<description><![CDATA[Description for Customer]]></description>
<display-name>Name for Customer</display-name>
<ejb-name>Customer</ejb-name>
<home>com.sf.ejb.CustomerHome</home>
<remote>com.sf.ejb.Customer</remote>
<ejb-class>com.sf.ejb.CustomerBean</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><![CDATA[/spring-config-server.xml]]></env-entry-value>
</env-entry>
</session>
CustomerBean implements ICustomer which is the business logic interface.
I am using JNDI template with SimpleRemoteStatelessSessionProxyFactoryBean.
In my client I see no trace of Home and Remote interface.
Only the ICustomer is used cast the lookedup bean.
If i delete the Home and Remote interfaces from classpath, i get an exception.
Can someone explain , how the Home and remote interfaces work woth Proxy and Jndi template.
My Client config.xml
<beans>
<bean id="jndiTemplate"
class="org.springframework.jndi.JndiTemplate">
<constructor-arg>
<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>
</constructor-arg>
</bean>
<bean id="customerEjb"
class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">
<property name="jndiTemplate"><ref bean="jndiTemplate"/></property>
<property name="jndiName">
<value>ejb/Customer</value>
</property>
<property name="businessInterface">
<value>com.sf.intf.ICustomer</value>
</property>
</bean>
</beans>
My Client Code
ClassPathXmlApplicationContext appContext =
new ClassPathXmlApplicationContext(
new String[] {"spring-config-client.xml"});
BeanFactory factory = (BeanFactory) appContext;
//ejb test
// Try 1
try{
ICustomer customer1=(ICustomer)factory.getBean("customerEjb" );
System.out.println(customer1.getCustomer(6));
ICustomer customer2=(ICustomer)factory.getBean("customerEjb" );
if(customer1==customer2)
System.out.println("Singleton");
else
System.out.println("Non Singleton");
System.out.println(customer2.getCustomer(10));
}catch(Exception e)
{
e.printStackTrace();
}
Thanks
Kevin


Reply With Quote