Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI lokup of EJB in Spring Controller

 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • 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
Java Spring
  • Mark post as helpful
  • send pies
  • 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
Java Spring
  • Mark post as helpful
  • send pies
  • 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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic