1 Reply Latest reply on Oct 30, 2005 6:26 PM by Frank van Westerop

    What XDoclet tag to use to get a local JNDI ref in jboss-web

    Frank van Westerop Newbie

      Hi,

      I'm strugling with XDoclet. I'm using JBossIDE to generate deployment descriptors for accessing an EJB from a servlet using it's local interface. I can't find the correct Xdoclet tag to use in my servlet to generate a correct jboss-web.xml file. This is what I've got:

      /**
       * Servlet Class
       *
       * @web.servlet name="Compute"
       * display-name="Compute"
       * description="Computes Fibonaci numbers 0..n for a given number n."
       *
       * @web.servlet-mapping url-pattern="/Compute"
       *
       * @web.ejb-local-ref name="ejb/myFibo"
       * description = "Reference to a bean that calculates Fibonaci numbers."
       * type="Session"
       * local="tutorial.interfaces.FiboLocal"
       * home="tutorial.interfaces.FiboLocalHome"
       *
       * @jboss.ejb-ref-jndi ref-name = "ejb/myFibo"
       * jndi-name = "FiboLocal"
       *
       *
       */
      public class ComputeServlet extends HttpServlet {
       ...
      }
      


      This (ofcourse) results in the following stuff in my jboss-web.xml file:

      <jboss-web>
      
       (...)
      
       <!-- EJB References -->
       <!--
       For additional ejb-ref tags add a merge file called jbossweb-ejb-ref.xml
       -->
       <ejb-ref>
       <ejb-ref-name>ejb/myFibo</ejb-ref-name>
       <jndi-name>FiboLocal</jndi-name>
       </ejb-ref>
      
       <!-- EJB Local References -->
      
      </jboss-web>
      


      Instead of the wanted:

      <jboss-web>
      
       (...)
      
       <!-- EJB References -->
       <!--
       For additional ejb-ref tags add a merge file called jbossweb-ejb-ref.xml
       -->
      
       <!-- EJB Local References -->
      
       <ejb-local-ref>
       <ejb-ref-name>ejb/myFibo</ejb-ref-name>
       <local-jndi-name>FiboLocal</local-jndi-name>
       </ejb-local-ref>
      
      </jboss-web>
      


      I understand the problem lies with the @jboss.ejb-ref-jndi tag, which only gets a remote jndi reference generated.

      What is the correct XDoclet tag to get a local jndi reference in my jboss-web.xml?

        • 1. Re: What XDoclet tag to use to get a local JNDI ref in jboss
          Frank van Westerop Newbie

          Found an alternative solution by using the XDoclet link property of the web.ejb-local-ref tag. XDoclet tags in servlet must be like this:

          /**
           * Servlet Class
           *
           * @web.servlet name="Compute"
           * display-name="Compute"
           * description="Computes Fibonaci numbers 0..n for a given number n."
           *
           * @web.servlet-mapping url-pattern="/Compute"
           *
           * @web.ejb-local-ref name="ejb/myFibo"
           * description = "Reference to a bean that calculates Fibonaci numbers."
           * type="Session"
           * local="tutorial.interfaces.FiboLocal"
           * home="tutorial.interfaces.FiboLocalHome"
           * link="Fibo"
           *
           */
          public class ComputeServlet extends HttpServlet {
           ...
          }
          


          This results in a <ejb-link> child tag under <ejb-local-ref> in web.xml.

          the value of the link property must match the XDoclet name attribute of the ejb.bean tag in the EJB class.

          Looks like this way JNDI is not used for lookup (makes sense for a local config) and this is a standard J2EE solution since relevant tags now show up in web.xml instead of jboss-web.xml.