8 Replies Latest reply on Apr 18, 2002 3:51 PM by yasirsk

    ejb-local-ref from servlet in 2.4.3 with Tomcat 4

    dim

      hey forum,

      just trying local ejbs from servlets for the first time, and things aint quite working as I'm expecting. I have my ear file, containing my jar and war, and have declared the following ejb-local-ref in my web.xml:
      <ejb-local-ref>
      <ejb-ref-name>ejb/UI</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>com.coxless.ui.UI</local-home>
      com.coxless.ui.UIHome
      </ejb-local-ref>

      but trying to do the lookup through

      java:comp/env/ejb/UI
      isn't working (ejb not bound). I'm not getting any exceptions deploying the code, and all my ejb-local-refs in the ejb jar are working fine, its just from the servlet to the ejb.

      I'm also using struts, and actually doing the lookup from an action class, so not directly from the servlet, but I couldn't see that being a problem.

      any ideas?

      tia
      dim


        • 1. Re: ejb-local-ref from servlet in 2.4.3 with Tomcat 4
          dim

          To reply to my own message. Looking at the code in AbstractWebContainer (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jboss/src/main/org/jboss/web/AbstractWebContainer.java) it looks as though this isn't done. Am I right here? If that is the case, is AbstractWebContainer the place to implement it (I assume so).

          cheers
          dim

          • 2. Re: ejb-local-ref from servlet in 2.4.3 with Tomcat 4
            hunterhillegas

            It looks like you are right. This isn't implemented and it means that local interfaces don't work at all in the Web container as far as I can tell...

            • 3. Re: ejb-local-ref from servlet in 2.4.3 with Tomcat 4
              dim

              fyi this is now done, and I've got local references from in-vm web tier working.

              I did however patch first, but you should be able to get away without it if you use defaults.

              • 4. Re: ejb-local-ref from servlet in 2.4.3 with Tomcat 4
                nmoldav

                Dmitri, what exactly did you patch? I'm trying 2.4.4 with Tomcat 4.02 and it isn't working.

                • 5. Re: ejb-local-ref from servlet in 2.4.3 with Tomcat 4

                  I am having the same problem with an unmodified JBoss 2.4.4+Tomcat4. How did you get local references from your servlet? I am using the MVCSoft PM but I don't think it matters much.

                  • 6. Re: ejb-local-ref from servlet in 2.4.3 with Tomcat 4
                    doomdoom

                    > fyi this is now done, and I've got local references
                    > from in-vm web tier working.
                    >
                    > I did however patch first, but you should be able to
                    > get away without it if you use defaults.

                    Can you please tell us how you did it ? I have been trying the same and it doesn't work at all for me . Even though my session beans can access entity beans locally and my EAR conatins the war and the ejb jar , I am unable to use the local ref to ejbs from my actions.

                    -manish

                    • 7. Re: ejb-local-ref from servlet in 2.4.3 with Tomcat 4
                      dim

                      hey all,

                      sorry - I haven't got it to work on 2.4.3, rather I've got it to work with CVS HEAD. I think it should work in the latest beta.

                      Essentially, I didn't change anything from what I was doing before - its just that the feature was implemented.

                      Here are the relevant file snippets:

                      web.xml

                       <ejb-local-ref>
                       <description>Reference to the home GreenKeeper EJB</description>
                       <ejb-ref-name>ejb/GreenKeeper</ejb-ref-name>
                       <ejb-ref-type>Session</ejb-ref-type>
                       <local-home>com.beerfucious.golf.interfaces.GreenKeeperLocalHome</local-home>
                       <local>com.beerfucious.golf.interfaces.GreenKeeperLocal</local>
                       <ejb-link>GreenKeeper</ejb-link>
                       </ejb-local-ref>
                      


                      jboss-web.xml is empty, but present

                      ejb-jar.xml:
                       <enterprise-beans>
                      
                       <!-- Session Beans -->
                       <session id="GreenKeeper">
                       <description><![CDATA[No Description.]]></description>
                      
                       <ejb-name>GreenKeeper</ejb-name>
                      
                       <local-home>com.beerfucious.golf.interfaces.GreenKeeperLocalHome</local-home>
                       <local>com.beerfucious.golf.interfaces.GreenKeeperLocal</local>
                       <ejb-class>com.beerfucious.golf.ejb.GreenKeeperSession</ejb-class>
                       <session-type>Stateless</session-type>
                       <transaction-type>Container</transaction-type>
                       ...
                      


                      and jboss.xml:
                       <session>
                       <ejb-name>GreenKeeper</ejb-name>
                       <local-jndi-name>GreenKeeper</local-jndi-name>
                       </session>
                      


                      I hope this helps some people out - I'm happy to answer quyestions if not (o:

                      cheesr
                      dim

                      • 8. Re: ejb-local-ref from servlet in 2.4.3 with Tomcat 4
                        yasirsk

                        Hi, i can't get this to work, please help!

                        web-xml:



                        <servlet-name>Test</servlet-name>
                        <jsp-file>/Test.jsp</jsp-file>




                        <ejb-local-ref>
                        <ejb-ref-name>NavigationServiceLocal</ejb-ref-name>
                        <ejb-ref-type>Session</ejb-ref-type>
                        <local-home>salsa.twist.entitys.navigation.NavigationServiceLocalHome</local-home>
                        salsa.twist.entitys.navigation.NavigationServiceLocal
                        <ejb-link>NavigationService</ejb-link>
                        </ejb-local-ref>


                        ejb-jar.xml:


                        NavigationService Session Bean
                        <display-name>NavigationService</display-name>
                        <ejb-name>NavigationService</ejb-name>
                        salsa.twist.entitys.navigation.NavigationServiceHome
                        salsa.twist.entitys.navigation.NavigationService
                        <local-home>salsa.twist.entitys.navigation.NavigationServiceLocalHome</local-home>
                        salsa.twist.entitys.navigation.NavigationServiceLocal
                        <ejb-class>salsa.twist.entitys.navigation.NavigationServiceEJB</ejb-class>
                        <session-type>Stateless</session-type>
                        <transaction-type>Container</transaction-type>
                        <ejb-local-ref>
                        <ejb-ref-name>NavigationLocal</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <ejb-link>Navigation</ejb-link>
                        <local-home>salsa.twist.entitys.navigation.NavigationLocalHome</local-home>
                        salsa.twist.entitys.navigation.NavigationLocal
                        </ejb-local-ref>


                        <ejb-local-ref>
                        <ejb-ref-name>NavigationServiceLocal</ejb-ref-name>
                        <ejb-ref-type>Session</ejb-ref-type>
                        <local-home>salsa.twist.entitys.navigation.NavigationServiceLocalHome</local-home>
                        salsa.twist.entitys.navigation.NavigationServiceLocal
                        </ejb-local-ref>


                        and jboss.xml:



                        <enterprise-beans>

                        <ejb-name>NavigationService</ejb-name>
                        <local-jndi-name>NavigationServiceLocal</local-jndi-name>

                        </enterprise-beans>





                        I get a not NavigationServiceLocal not bound error with the following code in Test.jsp:


                        NavigationServiceLocalHome psHome = (NavigationServiceLocalHome)
                        jndiContext.lookup("java:comp/env/NavigationServiceLocal");

                        i've also tried with java:comp/Navigation.....

                        also combinations with and without java:comp and with and without local. HELPPPPPP!

                        YSK