9 Replies Latest reply on Aug 7, 2002 7:32 PM by Tom

    JBoss-Jetty and LOCAL ejb interfaces - how?

    Paul Sabadin Newbie

      I wnat to get the much touted performance gains from having servlets AND ejb's run in the same virtual machine. (E.g. MyServlet--calls--MyEntityEJBLocal.do();)

      Can a JBoss guru PLEASE give code snippets or guidance for:

      1) any/all required ejb-jar.xml elements

      2) any/all required jboss.xml elements

      3) any/all required web.xml elements

      4) any/all required jboss-web.xml elements

      5) servlet code snippet showing how to JNDI find and access the entity local interface. (e.g. ... ctx.lookup(" ... ");)

      Your help is greatly appreciated.

      Thanks,
      Paul

      P.S. I know about session-facade-over-entitites pattern but this should be less important with servlet and ejb containers in the same VM - right?

        • 1. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
          Julian Gosnell Expert

          AFAIK JBoss will optimise calls across Remote interfaces to be by reference instead of value (between war/ejb-jar in ear), as well as across Local interfaces. - So you can't lose.

          If you want examples, find JBoss on SourceForge and check it out. Then look in the testsuite.

          If you need any more help than that, have a look round the web, there must be thousands of J2EE tutorials out there.


          Jules

          • 2. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
            Paul Sabadin Newbie

            Thanks Jules, but ...

            Appreciate your postback, but frankly I need better than "AFAIK." I'd like unequivocal statements - if possible.

            If I cast the returned object from a standard Context.lookup() to a "MyRemoteIF" type this suggests an IIOP skeleton WHICH, I believe, maintains much of the plumbing required to marshall and serialize over the TCP/IP stack (big performance hit). Are you saying that in JBoss local and remote IF's are identical? Come back to me, Jules.

            REMEMBER, the ultimate objective here is how to configure and use local ejb interfaces from Jetty-hosted servlets (see original post).

            Can anyone else chime in and clarify for us? How about this ... PLEASE?

            Much thanks,
            Paul

            • 3. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
              Tsvetan Stoyanov Newbie

              Nothing special for the local interfaces. Simply replace ejb-ref in ejb.xml with ejb-local-ref. jboss-web.xml remains unchanged. Then lookup you local home from a servlet just like you do it from an EJB.

              P.S. Don't use the web tier like a session facade. Imagine that you set/get 10 properties of an entity from a servlet. Then you will have 10 different transactions - one for every set/get... and so on...

              • 4. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
                Paul Sabadin Newbie

                To Tsvetan and other off-topic posters - see message after "*****". Always stay on topic or you dilute the value of the forums! Appreciate responses but sometimes more harm than good.

                REPEAT:
                I want to call a LOCAL LOCAL LOCAL EJB INTERFACE FROM JETTY SERVLET (E.g. MyServlet--calls--MyEntityEJBLocal.do();)

                The test suite does not appear to exercise this feature!

                Can a JBoss guru PLEASE give code snippets or guidance for:

                1) any/all required ejb-jar.xml elements

                2) any/all required jboss.xml elements

                3) any/all required web.xml elements

                4) any/all required jboss-web.xml elements

                5) servlet code snippet showing how to JNDI find and access the entity local interface. (e.g. ... ctx.lookup(" ... ");)

                Your help is greatly appreciated.

                *********************************************************
                Others , a note to ask you - PLEASE stay on topic.

                Tsvetan posted two incorrect response to my questions. The first mis-interpreted my question and the second was unsolicited architectural opinion.

                Tsvetan,
                Thanks for posting a reply. You answered a question that I did NOT ask. I needed an answer that WORKED for the WEB TIER (web.xml NOT ejb-jar.xml). What you suggested does NOT work for me IN THE WEB TIER (FROM A SERVLET)! BTW, YOU SHOULD NOT ALWAYS USE A SESSION BEAN FACADE - e.g. ADDRESS OBJECT CHANGE OF ADDRESS WITH A BULK DATA-OBJECT METHOD.

                Please, in the future, understand the explicit questions asked within a post and THEN reply ONLY to the questions ASKED as other, unsolicited, answers (such as yours regarding facades) tend to veer the thread OFF topic. Then, later readers of the thread see your off-tpic post and NO answer to original questions are EVER obtained!

                • 5. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
                  Tsvetan Stoyanov Newbie

                  Hi, Paul.
                  It seams that you even didn't try to understand what is written in my post. Ok ejb-jar.xml is a mistake. The ejb-local-ref element is in web.xml of course. This is the only wrong piece of my post. Also note that there isn't such thing like JETTY SERVLET...:))

                  And this is a part of an web.xml:

                  <ejb-local-ref>
                  <ejb-ref-name>ejb/MailServiceHome</ejb-ref-name>
                  <ejb-ref-type>Session</ejb-ref-type>
                  <local-home>com.tts.shop.ejb.interfaces.MailServiceHome</local-home>
                  com.tts.shop.ejb.interfaces.MailService
                  <ejb-link>MailService</ejb-link>
                  </ejb-local-ref>

                  The coresponding declaration in jboss-web.xml is:
                  <ejb-ref>
                  <ejb-ref-name>ejb/MailServiceHome</ejb-ref-name>
                  <jndi-name>MailService</jndi-name>
                  </ejb-ref>


                  P.S. It's up to you to use DTOs from your entity beans but this is bad design since EJB 2.0. Wonder why? See Floyd Marinescu's EJB Design Patterns.

                  • 6. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
                    Tsvetan Stoyanov Newbie

                    Hi, Paul.
                    It seams that you even didn't try to understand what is written in my post. Ok ejb-jar.xml is a mistake. The ejb-local-ref element is in web.xml of course. This is the only wrong piece of my post. Also note that there isn't such thing like JETTY SERVLET...:))

                    And this is a part of an web.xml:

                    <ejb-local-ref>
                    <ejb-ref-name>ejb/MailServiceHome</ejb-ref-name>
                    <ejb-ref-type>Session</ejb-ref-type>
                    <local-home>com.tts.shop.ejb.interfaces.MailServiceHome</local-home>
                    com.tts.shop.ejb.interfaces.MailService
                    <ejb-link>MailService</ejb-link>
                    </ejb-local-ref>

                    The coresponding declaration in jboss-web.xml is:
                    <ejb-ref>
                    <ejb-ref-name>ejb/MailServiceHome</ejb-ref-name>
                    <jndi-name>MailService</jndi-name>
                    </ejb-ref>


                    P.S. It's up to you to use DTOs from your entity beans but this is bad design since EJB 2.0. Wonder why? See Floyd Marinescu's EJB Design Patterns.

                    • 7. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
                      Adrian Brock Master

                      First, the testsuite contains an ejb-local-ref example
                      of a war accessing an ejb in the same ear.

                      http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jbosstest/src/resources/web/WEB-INF/jbosstest-web.xml

                      Second, if you have a separate war, you will need to
                      lookup into global jndi. The local interfaces are bound by
                      default at local/<your-ejb-name>, but you can override
                      this with a jboss.xml entry for your ejb.

                      Be careful, outside an ear there is no dependency,
                      restarting your ejb does not restart the war so you
                      will get ClassCastException on 3.0 if you do not restart
                      the war as well.

                      Third, Remote interfaces will use the local invocation
                      path where possible. It depends on your version and
                      packaging.

                      For 3.0 the local path will always be used inside the
                      same VM (no serialization/marshalling). This is due
                      to the UnifiedClassLoaders. The web containers are
                      configured to use the UnifiedClassLoaders not the
                      2.3 servlet classloader.

                      For 2.4 it depends on class visibility. Where the war
                      and ejb can share classes marshalling does not occur.

                      Regards,
                      Adrian

                      • 8. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
                        Paul Sabadin Newbie

                        Thanks both Tsvetan and Adrian. I'll try as you suggest. I believe the problem has been my misunderstanding of JNDI naming scopes both within and independent-of an ear file (my war is not in an ear file).

                        I will post here once I get it going (or be back here on my knees praying for more help).

                        P.S. Thanks for keeping it tight and staying on topic. I see a lot of posts meander into no-solution oblivion which hurts the whole forum process.

                        Paul

                        • 9. Re: JBoss-Jetty and LOCAL ejb interfaces - how?
                          Tom Newbie

                          Hi, I'm also running into this problem with tomcat embedded. I've got a separate War file, and tried to use the ENC name, but it doesn't seem to be working. Any thoughts? What is the jboss-web.xml file doing for you in this case? The examples I've seen thus far don't appear to be using it... am I missing something. I can do local interfaces with no problem from bean to bean.

                          Can someone provide an example of this when the war file is seperated out? I'd sure appreciate it.
                          Regards, Tom