0 Replies Latest reply on Apr 5, 2006 12:11 PM by Christos Nicolaou

    Calling an EJB from a different application on the same Jbos

    Christos Nicolaou Newbie

      I have two application packed in two different ear files and I want from a class in one ear file to access an ejb in the other file. Note that the class is not an ejb. I know that the ejb is deployed correctly because another application I have on Tomcat can access it.

      The ejb-jar.xml in the ear file of the ejb looks like this


      ... and the jboss.xml like this


      The code in the class where I lookup the ejb is like:

      private static NPSystem remoteConnect() throws Exception{
      NPSystem bean;
      Object reference = (new InitialContext()).lookup("java:comp/env/NPSystem");
      NPSystemHome home = (NPSystemHome)PortableRemoteObject.narrow(reference,NPSystemHome.class);
      bean = home.create();
      }catch(Exception e){
      throw e;
      return bean;
      }//end remoteConnect

      My problem is that I don't know how to configure the ejb-jar.xml and jboss.xml in the ear file where my calling class resides so that lookup("java:comp/env/NPSystem") would point to my ejb.

      Some code I found on the internet is not accepted by jboss. For example I tried this in ejb-jar.xml





      The above is not accepted because the attributes <ejb-name>,<ejb-class> etc must be declared...

      I hope you have an idea of how to solve this.