1 Reply Latest reply on Jul 19, 2002 3:25 AM by ongbp

    Tomcat (standalone 4.0.1) + JNDI + EJB (JBoss 3.0)

    giluka

      I've a problem:
      i want to call my EJB (running on a remote machine) from a servlet (running on my local machine).
      My code is:

      --SERVLET ----------------------------------------------
      Properties env = new Properties();
      env.setProperty(jndiContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.setProperty(jndiContext.PROVIDER_URL, "remote-machine:1099");
      env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");

      jndiContext = new InitialContext(env);

      com.app.ejb.MyEJBLocalHome myhome;
      try{
      myhome=(com.app.ejb.MyEJBLocalHome)jndiContext.lookup(jndiContextName);
      com.app.ejb.MyEJBLocal remoteBean=myhome.create("a","b","c","d","e","f");
      }
      catch (Exception e){
      System.out.println("---exception:"+e);
      }

      --WEB.XML------------------------------------------------

      <ejb-ref>
      <ejb-ref-name>ejb/myEJBJNDIName</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      com.app.ejb.MyEJBLocalHome
      com.app.ejb.MyEJBLocal
      </ejb-ref>

      --SERVER.XML-----------------------------------------

      ...
      <ejb-ref>
      <ejb-ref-name>ejb/myEJBJNDIName</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      com.app.ejb.MyEJBLocalHome
      com.app.ejb.MyEJBLocal
      </ejb-ref>
      ...

      -------------------------------------------------------
      When i call servlet (after launched JBoss on remote machine) the result is that execution of serlet stops (without any message !) when tomcat try to lookup the object ...
      If i stop JBoss an re-launch servlet (on the other hand) exception is: "javax.naming.NameNotFoundException".
      So, i think that link between my tomcat in local and jboss on remote is established !

      JNDI name invoked is also same in jboss.xml of ejb


      can you help me please ?