2 Replies Latest reply on Mar 8, 2002 12:45 AM by jian gao

    client lookups

    garyg Novice

      I'm trying to call an entity bean from a client.

      From the JBoss docs, chpt. 7 ...
      "JBoss does not currently allow you to use the java:comp/env namespace to call your beans from your clients."

      So does that mean I can't use the following line from within my client, which currently runs on the same machine but will be running on different machines.

      Object result = ctx.lookup "java:comp/env/ejb/MyBean");

      This is currently how it's defined in ejb-jar.xml, and I'm trying to figure out what to write in jboss.xml.


      Any help much appreciated!

        • 1. Re: client lookups
          garyg Novice

          I'm currently getting errors like this:

          [AutoDeployer] org.jboss.deployment.J2eeDeploymentException: Error while starting acais-1.0.ear: Could not deploy file:/u/public/JBoss-2.4.0_Tomcat-3.2.3/jboss/tmp/deploy/Default/acais-1.0.ear, Cause: org.jboss.ejb.DeploymentException: Could not deploy file:/u/public/JBoss-2.4.0_Tomcat-3.2.3/jboss/tmp/deploy/Default/acais-1.0.ear, Cause:org.jboss.ejb.DeploymentException: Error in jboss.xml for Bean MyBean: ejb-ref MyBean found in jboss.xml but not in ejb-jar.xml

          And do I maybe have to add anything to application.xml?

          • 2. Re: client lookups
            jian gao Newbie

            About calling EJB in another JVM
            I tried , it might not what you want, but i really succeeded.
            The code:

            import javax.servlet.*;
            import javax.servlet.http.*;
            import java.io.*;
            import java.util.*;
            import javax.naming.*;
            import javax.rmi.PortableRemoteObject;
            import org.jnp.interfaces.NamingContextFactory;
            import org.jnp.interfaces.*;
            import quay.myquayHome;
            import quay.myquay;
            import quay.myquayBean;

            public class EJBClientTest extends HttpServlet {
            private static final String CONTENT_TYPE = "text/html; charset=GBK";

            public void init() throws ServletException {

            public void doGet(HttpServletRequest request, HttpServletResponse

            response) throws ServletException, IOException {
            PrintWriter out = response.getWriter();
            out.println("Remote EJB Test Panel");
            out.println("<h1>Remote EJB Test Page.</h1>");


            System.out.println("Before myEJBWork");
            String tmpRst=myEJBWork();
            System.out.println("After myEJBWork");
            }catch(Exception e){
            out.print("Error when accessing EJB");


            public void doPost(HttpServletRequest request, HttpServletResponse

            response) throws ServletException, IOException {

            private String myEJBWork() throws Exception{
            try {
            myquay tmpbean = findMyBeanHome().create();
            return tmpbean.say();
            }catch(NamingException e){
            return "Error in myEJBWork";

            private myquayHome findMyBeanHome()
            throws NamingException {
            Context context = getInitialContext();
            Object object = context.lookup("quay/myquay");
            return (myquayHome)PortableRemoteObject.narrow(object,


            public Context getInitialContext()
            throws NamingException {

            Properties env = new Properties();


            env.setProperty(Context.PROVIDER_URL, getNameServerURL());

            InitialContext jndiContext = new InitialContext(env);
            return jndiContext;

            private String getInitialContextFactoryClassName(){
            return "org.jnp.interfaces.NamingContextFactory";

            private String getURLPackageInterface(){
            return "org.jnp.interfaces";

            private String getNameServerURL(){
            return "localhost:1099";