Monday, March 25, 2013

javax.naming.NameNotFoundException: org.mk.rc.intf.StaffsBeanRemote

When calling an EJB, I got an error like the following....

com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=org.mk.rc.client.Client/staffsBean,Remote 3.x interface =org.mk.rc.intf.StaffsBeanRemote,ejb-link=null,lookup=,mappedName=,jndi-name=org.mk.rc.intf.StaffsBeanRemote,refType=Session into class org.mk.rc.client.Client: Lookup failed for 'java:comp/env/org.mk.rc.client.Client/staffsBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:703)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:470)
....

Caused by: javax.naming.NameNotFoundException: org.mk.rc.intf.StaffsBeanRemote#org.mk.rc.intf.StaffsBeanRemote not found
at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
..... 

The problem is, I didn't add StaffsBeanRemote bean name to application-client.xml file. Just add as follow and works fine. 

<ejb-ref>
    <ejb-ref-name>StaffsBean</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <remote>org.mk.rc.intf.StaffsBeanRemote</remote>
 </ejb-ref>

Enjoy :-)


No comments:

Post a Comment