5 Replies Latest reply on Oct 23, 2002 12:15 AM by sgturner

    EJB client jars

    eemrich

      Forgive my ignorance but I can't find any reference on creating a client jar for an EJB in JBOSS. Let's say I want to call a standalone SS Bean from a web component. How does the client (servlet or jsp) know how to find a bean? I know that it looks it up in the JNDI tree, but I want to know how it knows the object type if it doesn't have a client jar? Do I just put a copy of the ejb jar in the web component WEB-INF/lib directory? With Weblogic you have to run ejbc against the bean to generate the client jar which contains the RMI stubs, similarly to what you do with the Sun reference implementation. Please help. Thanks--

        • 1. Re: EJB client jars

          I can´t understood why you need the client jar on the web application. You could declare a reference on the sun-j2ee.xml to the outter EJB like:
          <ejb-ref>
          <ejb-ref-name></ejb-ref-name>
          <jndi-name><jndi-name></jndi-name>
          </ejb-ref>
          Also, incude the ejb-ref on the web.xml:

          <ejb-ref>
          <ejb-ref-name></ejb-ref-name>
          <ejb-ref-type>Session</ejb-ref-type>
          ...
          ...
          <ejb-link></ejb-link>
          </ejb-ref>

          them you have to include on the war-ic.war the home and interface classes of your beans (or a reference to them on the manifest)

          Hope it helps!

          • 2. Re: EJB client jars

            I can´t understood why you need the client jar on the web application. You could declare a reference on the sun-j2ee.xml to the outter EJB like:
            <ejb-ref>
            <ejb-ref-name></ejb-ref-name>
            <jndi-name><jndi-name></jndi-name>
            </ejb-ref>
            Also, incude the ejb-ref on the web.xml:

            <ejb-ref>
            <ejb-ref-name></ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            ...
            ...
            <ejb-link></ejb-link>
            </ejb-ref>

            them you have to include on the war-ic.war the home and interface classes of your beans (or a reference to them on the manifest)

            Hope it helps!

            • 3. Re: EJB client jars
              noir

              > Forgive my ignorance but I can't find any reference
              > on creating a client jar for an EJB in JBOSS. Let's
              > say I want to call a standalone SS Bean from a web
              > component. How does the client (servlet or jsp) know
              > how to find a bean? I know that it looks it up in the
              > JNDI tree, but I want to know how it knows the object
              > type if it doesn't have a client jar?

              No, Java can't do any magic and needs .classes of the bean but not all of them.

              >Do I just put a
              > copy of the ejb jar in the web component WEB-INF/lib
              > directory?

              Yes, it works fine if you don't care about jar size.

              You need some Jboss libraries, too (ones from %jbossdir%/client as I recall.) As I understood, these libraries contain "universal" RMI stubs for beans.

              • 4. Re: EJB client jars
                agilbert201

                Does one infer from this that JBoss can not generate a client jar per Spec? Ie using

                <ejb-client-jar>

                in ejb-jar.xml

                • 5. Re: EJB client jars
                  sgturner

                  Due to JBoss superior architecture over the "other" app servers, there is no need to generate stubs and skeletons. JBoss makes heavy use of reflection and dynamic proxies. Almost any object you get out of Jndi is a dynamic proxy object whose invocation handler implements the correct interfaces. Follow these instructions for packaging your ejbs:
                  http://www2.theserverside.com/resources/articles/J2EE-Deployment/chapter.html
                  If your client is running in a JVM that is not the same JVM that JBoss runs in, use the jboss/client jars in your class path, plus your own interfaces.