2 Replies Latest reply on Jun 16, 2003 9:30 PM by manfredb

    which interfaces if (remote or local) when accessing ejb's f

    manfredb Newbie

      Hey,
      I want to access my ejb from a jsp or a servlet. All those files are packaged in a war file. Which interfaces must be extended (EJBObject/EJBHome or EJBLocalObject/EJBLocalHome). As I understand it, Local interfaces avoid the intervention of rmi, so the performance is better. Is it possible to use local interfaces from a servlet/jsp to gain that performance boost?
      If it is possible, how should the lookup method on the client side be coded? And what entries in the configuration files (ejb-jar.xml, jboss.xml, web.xml, jboss-web.xml) must be changed?

      I have read the GetStarted Documentation and the postings in this topic list but didn't find any hint on this issue.

      Any help would be appreciated
      Manfred

        • 1. Re: which interfaces if (remote or local) when accessing ejb
          Juha Lindfors Master

          As long as your servlet container is embedded into the same process you can use local interfaces from your servlets. There isn't anything special you need to do (apart from the usual and <local-home> declarations in your ejb-jar.xml), simply lookup the local proxy from the JNDI (local-jndi-name entry in your jboss.xml).

          However, in case of JBoss, the same pass-by-reference optimization is done automatically even if you only expose a remote interface. The proxy is smart enough to detect that you are attempting to make a local call and optimize the argument passing semantics.

          • 2. Re: which interfaces (remote or local) when accessing ejb's
            manfredb Newbie

            Hallo Juha,

            many thanks for your response. I did it like you explained. Now it works. This time it was much simpler as I thought.

            The necessary definitions if someone else is interest in it

            ejb-jar.xml:
            <ejb-jar>
            <enterprise-beans>

            <display-name>Cabin</display-name>
            <ejb-name>Cabin</ejb-name>
            <local-home>untitled8.CabinHome</local-home>
            untitled8.Cabin
            <ejb-class>untitled8.CabinBean</ejb-class>
            ...
            // other necessary definitions
            </ejb-jar>


            jboss.xml:

            <enterprise-beans>

            <ejb-name>Cabin</ejb-name>
            <local-jndi-name>ejb/CabinHome</local-jndi-name>

            </enterprise-beans>


            display.jsp:

            public void jspInit() {
            ...
            Context jndiContext = new InitialContext();
            CabinHome home = (CabinHome)jndiContext.lookup("ejb/CabinHome");
            ...

            Once more many thanks to you. It was a great help.

            Manfred