Results 1 to 2 of 2

Thread: EJB Remote interface binding through business delegate

  1. #1
    Join Date
    Jan 2009
    Location
    punjab,pakistan
    Posts
    2

    Default EJB Remote interface binding through business delegate

    i need to use business delegate pattern in my client class so that client dont need to catch remote exception. now problem is spring throws the exception. every thing goes good when i use local interface, but remote interface causing problem.
    please inspect the code below.
    Exception is:
    Code:
    org.springframework.remoting.RemoteLookupFailureException: EJB instance [echoService:Stateless] is not a Remote Stateless Session Bean
     	at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.newSessionBeanInstance(AbstractRemoteSlsbInvokerInterceptor.java:207)
     	at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.getSessionBeanInstance(SimpleRemoteSlsbInvokerInterceptor.java:108)
     	at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.doInvoke(SimpleRemoteSlsbInvokerInterceptor.java:74)
    	at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.invoke(AbstractRemoteSlsbInvokerInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy68.echo(Unknown Source)
    Remote interface:
    Code:
    public interface EchoServiceSession extends javax.ejb.EJBObject{
    	public String echo(String message) throws java.rmi.RemoteException;
    }
    local interface:
    Code:
    public interface EchoServiceLocal extends EchoService, EJBLocalObject {
    
    }
    business interface:
    Code:
    public interface EchoService {
    	public String echo(String message);
    }
    EJB class:
    Code:
    public class EchoServiceEJB extends AbstractStatelessSessionBean
    		implements
    			EchoService {
    
    	private static final String BEAN_NAME = "echoService";
    	private EchoService service;
    
    	protected void onEjbCreate() throws CreateException {
    		service = (EchoService) getBeanFactory().getBean(BEAN_NAME);
    	}
    
    	public String echo(String message) {
    		return service.echo(message);
    	}
    }
    web layer applicationContext.xml is:
    Code:
    <bean id="EchoService"
    		class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean"
    		lazy-init="true">
    		<property name="jndiName">
    			<value>echoService</value>
    		</property>
    		<property name="businessInterface">
    			<value>com.test.echo.EchoService</value>
    		</property>
    		<property name="homeInterface">
    			<value>com.test.echo.EchoServiceSessionHome</value>
    		</property>
    	</bean>
    ejb-jar.xml:
    Code:
    <session>
    			<description>Echo Service Bean</description>
    			<ejb-name>EchoServiceEJB</ejb-name>
    			<home>com.test.echo.EchoServiceSessionHome</home>
    			<remote>com.test.echo.EchoServiceSession</remote>
    			<local-home>com.test.echo.EchoServiceHome</local-home>
    			<local>com.test.echo.EchoServiceLocal</local>
    			<ejb-class>com.test.echo.EchoServiceEJB</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>
    Thanks for the help.

  2. #2
    Join Date
    Jan 2009
    Location
    punjab,pakistan
    Posts
    2

    Default

    ok the problem was simple. i was doing a mistake by not mentioning remote JNDI name.
    jboss.xml
    Code:
    <session>
    			<ejb-name>EchoServiceEJB</ejb-name>
    			<jndi-name>echoServiceRemote</jndi-name>
    			<local-jndi-name>echoService</local-jndi-name>
    		</session>
    app-context.xml
    Code:
    <bean id="EchoService"
    		class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean"
    		lazy-init="true">
    		<property name="jndiName">
    			<value>echoServiceRemote</value>
    		</property>
    		<property name="businessInterface">
    			<value>com.test.echo.EchoService</value>
    		</property>
    		<property name="jndiTemplate">
    			<ref bean="RemoteContextJndi" />
    		</property>
    	</bean>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •