File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes How to use an EJB, deployed in another server? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to use an EJB, deployed in another server?" Watch "How to use an EJB, deployed in another server?" New topic

How to use an EJB, deployed in another server?

prasad kulkarni
Ranch Hand

Joined: Mar 19, 2006
Posts: 66
I have 2 websphere test-environments running on same machine but with different ports. I have deployed the EJB on one server say server1 & I have an web project runnning on another server say server2. I have copied the home & remote interfaces to Web application running on server2. When I try to access the EJB of server1 from servlet of server2, it is giving exception
javax.naming.NameNotFoundException: ejb/com/ejb/MyEJBHome. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound

The jndi name of my EJB is "ejb/com/ejb/MyEJBHome". Why I have the exception & what is solution to this? After getting exception I stop the server2 & then given the reference of the ejb-jar file to web application & then started server2 by rebuilding the web-application. But still I have same exception when I call my servlet . How can I solve this problem?

scjp, scwcd
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
sounds like your JNDI lookup is looking up the bean in the wrong server.

Masoud Kalali
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

ok , you are trying to access an EJB which is not in the same server that your jndi client resides.
so you should initiate the InitialContext with correct parameters.
what does correct parameters mean ?
at least :
so check this page and configure the initial context with corect port jndi endpoint url , then you will have no problem.

Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
I agree. Here's the link:
subject: How to use an EJB, deployed in another server?
It's not a secret anymore!