1

Issue: Can't seem to do a jndi look-up EJB 3 in Websphsere server through the spring. Keep getting Not found for my jndi name. I'm not seeing what I have wrong. For Websphere do you have to something different for the jndi name look-up?

Stack overflow Reference Question - EJB 3 injection into spring beans

Versions:

  1. Spring Version: 4.1.2
  2. WebSphere Server Version: 7.0.0.27

Spring Error:

Error creating bean with name 'myLocalEjb': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Context: WMTN123456Node10Cell/nodes/WMTN1234569Node10/servers/server1, name: ejb/myBean: First component in name myBean not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]

Spring Config JNDI Look-up

<jee:local-slsb id="myLocalEjb"
                     jndi-name="ejb/myBean"
                     business-interface="spring.ejbtest.MyBeanLocal"
    </jee:local-slsb>

<bean id="targetPOJO" class="different.pojo.localPOJO">
    <property name="injectedEJB3" ref="myLocalEjb"/>
</bean>

WebSphere Deployment Descriptor

<ejb-jar id="ejb-jar_ID" version="3.0" metadata-complete="false" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" > 
 <display-name> MyEJB</display-name> 
 <enterprise-beans> 
 <session> 
 <ejb-name> myBean</ejb-name> 
 <mapped-name> ejb/myBean</mapped-name> 
 <business-local> spring.ejbtest.MyBeanLocal</business-local> 
 <ejb-class> spring.ejbtest.MyBean</ejb-class> 
 <session-type> Stateless</session-type> 
 <service-ref> 
 <service-ref-name> service/someOtherService</service-ref-name> 
 <service-interface> some.other.service.MyHTTPService</service-interface> 
 <service-ref-type> some.other.service.MyHTTPService</service-ref-type> 
 <wsdl-file> META-INF/wsdl/MyHTTPServiceExport.wsdl</wsdl-file> 
 <service-qname> http://company.foo/service/Service/:MyHTTPService</service-qname> 
 </service-ref> 
 </session> 
 </enterprise-beans> 
<assembly-descriptor/> 
 </ejb-jar>
Community
  • 1
  • 1
haju
  • 1,278
  • 4
  • 20
  • 38

1 Answers1

1

Took me a while to get the right question on stack overflow to find the answer. I was confused with the example above and thought it used the mapped name as the jndi name. Instead IBM has a much longer naming context pattern for JNDI look-up.

IBM Docs: EJB JNDI Naming Convention

How to override the IBM default naming and reference it - See Ed Randall's answer. Explains how to override. Stack overflow answer

Spring look-up should be:

   <jee:local-slsb id="myLocalEjb"
                     jndi-name="ejblocal&#58;ejb/myBean"
                     business-interface="spring.ejbtest.MyBeanLocal"
    </jee:local-slsb>
Community
  • 1
  • 1
haju
  • 1,278
  • 4
  • 20
  • 38