• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNDI lokup of EJB in Spring Controller

 
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am trying to look up an EJB in a Spring Controller. But I am unable to get reference to the EJB and the lookup fails throwing a NameNotFoundException.
My application is deployed in TOMEE.
When I look up the same EJB in a servlet, the reference is obtained successfully, but somehow Spring is unable to get it.

Below is my configuration:
1) EJB Name: AuctionManagerImpl (Deployed as a part of JAR placed in WEB-INF/lib of the web application)
2) Spring Servlet XML entry:


3) Spring Controller has a member variable of EJB interface.


Also tried looking up with JNDITemplate:



Tried various combinations like AuctionManagerImplLocal,local/AuctionManagerImpl etc but no luck.
I can see the JNDI name binding in TOMEE logs as well but Spring Controller cant get to it.

Struggling for a long time so any help would be really appreciated!!!

Thanks in advance.

-Prajakta
 
Prajakta Acharya
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Spring container should know the server configuration where JNDI resource exists.
So, I guess following should be used:


But above values are for JBoss. Does anyone know respective values of TOMEE?
 
Prajakta Acharya
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I could get to the solution. Sharing it in order to contribute to the forum so anyone like me searching on web can get to it

Did following entry in the servlet configuration file.

<jee:jndi-lookup id="auctionManager"
jndi-name="AuctionManagerImplLocal"
cache="true"
resource-ref="false">
<jee:environment>
java.naming.factory.initial= org.apache.openejb.core.ivm.naming.InitContextFactory
java.naming.provider.url= http://localhost:8080/openejb/ejb
java.naming.factory.url.pkgs= org.apache.naming
</jee:environment>
</jee:jndi-lookup>

<bean name="/auction.htm" class="org.cts.AuctionController">
<property name="auctionManager" ref="auctionManager"/>
</bean>
 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic