9 Replies Latest reply on Oct 16, 2003 8:17 PM by crosscourt

    ejb-ref in web.xml

    crosscourt Newbie

      Hi,

      what is the correct syntax for the ejb-ref tag?
      I tried the following but jboss complains about the ejb-link?

      I am trying to deploy a ear file which contains a jar for my ejbs. I deploy a test.war file for cactus that test my "local" ejbs but i can't get the ejb-link right? I can still lookup the ejb through a jndi lookup but I want to use COMP_NAME lookup (is it better?).

      where "ejb/user/UserValidatorLocal" is the local-jndi-name.

      <ejb-local-ref>
      <ejb-ref-name>ejb/user/UserValidatorLocal</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>tds.interfaces.UserValidatorLocalHome</local-home>
      tds.interfaces.UserValidatorLocal
      <ejb-link>ejb/user/UserValidatorLocal</ejb-link>
      </ejb-local-ref>

      It used to work when i use
      <ejb-link>tds.jar#user/UserValidatorLocal</ejb-link>

      but now i deploy with tds.ear? and nothing works

      thanks

        • 1. Re: ejb-ref in web.xml
          crosscourt Newbie

          and the error:

          no ejb-link match, use jndi-name in jboss-web.xml

          • 2. Re: ejb-ref in web.xml
            Adrian Brock Master

            <ejb-link>{<ejb-name> you want to reference}</ejb-link>

            or

            <ejb-link>relative path to jar#{<ejb-name> you want to reference}</ejb-link>

            Regards,
            Adrian

            • 3. Re: ejb-ref in web.xml
              crosscourt Newbie

              what if the jar is inside a ear?
              so EAR has the ejb jar and web app war?

              thanks

              • 4. Re: ejb-ref in web.xml
                crosscourt Newbie

                More info:

                I'm trying to access local ejbs from normal java classes in my webapp inside the .war file through the java:comp namespace.

                • 5. Re: ejb-ref in web.xml
                  Adrian Brock Master

                  Prove to me you know what you are doing:

                  1) Show the ejb deployment descriptors, specifically what
                  <local-jndi-name> does the local interface have.
                  default is local/<ejb-name> if you don't change it jboss.xml

                  2) Show the packaging of the ear so I can see where the
                  ejb jar and war are located and what their names are.
                  jar -tf tds.ear

                  3) Show the web.xml you are actually using.

                  4) Post the full error message

                  Regards,
                  Adrian

                  • 6. Re: ejb-ref in web.xml
                    crosscourt Newbie

                    yeah, i don't really know what i'm doing but here we go:

                    With xdoclet, i define the local jndi name
                    ===============================
                    * @ejb.bean
                    * name="service/AdminService"
                    * type="Stateless"
                    * display-name="Administration Service Session Bean"
                    * local-jndi-name="ejb/service/AdminServiceLocal"
                    * view-type="local"
                    *
                    ===============================
                    jboss.xml


                    <ejb-name>service/AdminService</ejb-name>
                    <local-jndi-name>ejb/service/AdminServiceLocal</local-jndi-name>


                    ===============================

                    jar -tf tds.ear

                    META-INF/
                    META-INF/MANIFEST.MF
                    tds.jar
                    tds.war
                    META-INF/application.xml

                    ===============================

                    web.xml

                    <?xml version="1.0" encoding="UTF-8"?>
                    <!DOCTYPE web-app
                    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
                    "http://java.sun.com/dtd/web-app_2_3.dtd">

                    <web-app>

                    <!-- Action Servlet Configuration -->

                    <servlet-name>action</servlet-name>
                    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
                    <init-param>
                    <param-name>config</param-name>
                    <param-value>/WEB-INF/struts-config.xml</param-value>
                    </init-param>
                    <init-param>
                    <param-name>debug</param-name>
                    <param-value>3</param-value>
                    </init-param>
                    <init-param>
                    <param-name>detail</param-name>
                    <param-value>3</param-value>
                    </init-param>
                    <load-on-startup>2</load-on-startup>



                    <!-- Action Servlet Mapping -->
                    <servlet-mapping>
                    <servlet-name>action</servlet-name>
                    <url-pattern>*.do</url-pattern>
                    </servlet-mapping>


                    <!-- The Welcome File List -->
                    <welcome-file-list>
                    <welcome-file>index.jsp</welcome-file>
                    </welcome-file-list>

                    <!-- Application Tag Library Descriptor -->

                    <!-- Struts Tag Library Descriptors -->
                    ...
                    <!-- EJB References -->
                    <ejb-local-ref>
                    <ejb-ref-name>service/AdminService</ejb-ref-name>
                    <ejb-ref-type>Session</ejb-ref-type>
                    <local-home>com.cmcrc.tds.interfaces.AdminServiceLocalHome</local-home>
                    com.cmcrc.tds.interfaces.AdminServiceLocal
                    <ejb-link>TradeDataService.jar#service/AdminService</ejb-link>
                    </ejb-local-ref>

                    </web-app>

                    ==================================
                    error:

                    11:52:09,437 ERROR [AdminServiceDelegateImpl] Cannot find AdminServiceEJB
                    11:52:09,437 ERROR [STDERR] javax.naming.NameNotFoundException: ejb not bound
                    11:52:09,437 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
                    11:52:09,437 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
                    11:52:09,437 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
                    11:52:09,437 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
                    11:52:09,437 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:256)
                    11:52:09,437 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
                    11:52:09,437 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:642)
                    11:52:09,437 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
                    11:52:09,437 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:347)
                    11:52:09,437 ERROR [STDERR] at tds.interfaces.AdminServiceUtil.getLocalHome(AdminServiceUtil.java:28)
                    11:52:09,437 ERROR [STDERR] at tds.admin.delegate.support.AdminServiceDelegateImpl.(AdminServiceDele
                    gateImpl.java:31)

                    ======================================
                    AdminServiceDelegateImpl.java is a class inside the war file that tries to locate the AdminServiceEJB with the util class generated from xdoclet which uses
                    public static final String COMP_NAME="java:comp/env/ejb/service/AdminServiceLocal";

                    i tried diff combinations of <ejb-link> and only one jboss doesn't complain is
                    TradeDataService.jar#service/AdminService


                    thanks for you time

                    • 7. Re: ejb-ref in web.xml
                      crosscourt Newbie

                      oh, TradeDataService.jar == tds.jar
                      sorry for the inconsistency

                      • 8. Re: ejb-ref in web.xml
                        Adrian Brock Master

                        <ejb-ref-name>service/AdminService</ejb-ref-name>
                        ==
                        java:comp/env/service/AdminService

                        Regards,
                        Adrian

                        • 9. Re: ejb-ref in web.xml
                          crosscourt Newbie

                          ok thanks,

                          i think this works
                          <ejb-ref-name>ejb/service/AdminServiceLocal</ejb-ref-name>

                          but what about ejb-ref for an external war for my test classes?

                          so i deploy tds.ear and test.war and i need to access the ejb from the classes in test.war?