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

    Calling an EJB from a different application on the same Jbos

    nicolaou

      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

      <session.>
      <description.>NPSystemImpl</description.>
      <display-name>NPSystemImpl</display-name>
      <ejb-name>NPSystem</ejb-name>
      <home.>cy.com.netinfo.netpins.interfaces.NPSystemHome</home.>
      <remote.>cy.com.netinfo.netpins.interfaces.NPSystem</remote.>
      <ejb-class>cy.com.netinfo.netpins.ejb.NPSystemImpl</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>


      ... and the jboss.xml like this


      <ejb-name>NPSystem</ejb-name>
      <jndi-name>ejb/NPSystem</jndi-name>
      <method-attributes>
      </method-attributes>


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

      private static NPSystem remoteConnect() throws Exception{
      NPSystem bean;
      try{
      Object reference = (new InitialContext()).lookup("java:comp/env/NPSystem");
      NPSystemHome home = (NPSystemHome)PortableRemoteObject.narrow(reference,NPSystemHome.class);
      bean = home.create();
      }catch(Exception e){
      System.out.println(e.toString());
      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

      <ejb-jar>
      <enterprise-beans>

      NPSystem
      <ejb-ref>

      <ejb-ref-name></ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <home.>cy.com.netinfo.netpins.interfaces.NPSystemHome</home.>
      <remote.>cy.com.netinfo.netpins.interfaces.NPSystem</remote.>
      </ejb-ref>

      <enterprise-beans>
      <ejb-jar>

      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.