aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JNDI lokup of EJB in Spring Controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI lokup of EJB in Spring Controller" Watch "JNDI lokup of EJB in Spring Controller" New topic
Author

JNDI lokup of EJB in Spring Controller

Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

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


Regards,
Prajakta
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

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

Joined: Nov 08, 2012
Posts: 138

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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI lokup of EJB in Spring Controller