Bookmark Topic Watch Topic
  • New Topic

RMI error: Name is not bound in this Context  RSS feed

Nathan Pruett
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Sorry, this post really does belong in the EJB forum, as the problem is with the JNDI lookup. You should be looking up "java:comp/env/TestSession", not just "TestSession". JNDI contains data in a hierarchy, and "java:comp/env" is the root of this hierarchy.

Closing this post, since it belongs in EJB instead.
Chris Montgomery
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Report post to moderator
I initially had this post in the EJB section, but just noticed this group and decided it would be better off here.... sorry for the dup.


-EJB running in JBoss - client test code doing same thing works great.
-Struts running OUTSIDE of JBoss.
-Struts Action class (in Tomcat) is trying to connect to EJB (in JBoss) using RMI.

code is failing here:
-Object o = initial.lookup("TestSession"); (client code below)
-ERROR: Name TestSession is not bound in this Context


JNDIView Service List:
Global JNDI Namespace
+- TestSession (proxy: $Proxy53 implements interface com.test.TestSessionHome,interface javax.ejb.Handle)


import com.test.*;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.ejb.CreateException;

import java.rmi.RemoteException;
import java.util.Hashtable;

import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class testing extends Action{

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception, RemoteException {

System.out.println("Adding properties");
Context initial = new InitialContext();
System.out.println("Got initial context!");

Object o = initial.lookup("TestSession");

System.out.println("got object from lookup");
com.test.TestSessionHome home = (com.test.TestSessionHome)PortableRemoteObject.narrow(o, com.test.TestSessionHome.class);

System.out.println("got home object back and did remote narrow cast");
com.test.TestSession h = home.create();
System.out.println("got component interface");
System.out.println("called business method on component interface");
catch(Exception ex)
System.out.println("Exception: " + ex.toString());
return mapping.findForward("fail");

System.out.println("test = " + myBean.test("CHRIS"));

return mapping.findForward("success");



Everything *appears* to be okay, but I'm still quite new to this, so I really can't say.

Any ideas?

    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!