2 Replies Latest reply on Nov 11, 2010 7:49 AM by bharath sadanagiri

    How to use ejb3 in ejb2 using xdoclet

    bharath sadanagiri Newbie


      We have an EJB2 project, in this project xdoclets have been used. I have written an EJB3.0 stateless session bean, I am trying to use the EJB3.0 stateless SB in 2.0 MDB that has xdoclets. I have declared like the following


      * @jboss.depends     
      *      name="jboss.j2ee:jndiName=ERPayrollReceiver/AuditService/local,service=EJB"    
      * @ejb.ejb-ref ejb-name="AuditService"    
      *              view-type="local"      
      *              ref-name="ejb/AuditServiceLocal"    


      But I am getting the following compile time exception.


      [ejbdoclet] Generating EJB deployment descriptor (ejb-jar.xml).     
      [ejbdoclet] (XDocletMain.start                   53  ) Running XDoclet failed.     
      [ejbdoclet] (XDocletMain.start                   54  ) <<No such EJB defined: AuditService>>     
      [ejbdoclet] C:\SVN_DAS\ERPush\build\macros-include.xml:15: XDoclet failed.     
      [ejbdoclet] at xdoclet.DocletTask.start(DocletTask.java:471)  


      Any help can be appreciated.


        • 1. Re: How to use ejb3 in ejb2 using xdoclet
          jaikiran pai Master

          I haven't looked at XDoclet for more than 5 years now. I don't know what kind of support it has for EJB3.

          • 2. Re: How to use ejb3 in ejb2 using xdoclet
            bharath sadanagiri Newbie

            I got the solution for this problem
            I have choosen the last option, that is using the Xdoclet generated configuaration files.
            The following steps that I have followed
            1. I did changes on top of the XMLs that got generated using Xdoclets
            2. Create a LocalHome in ejb3.0 eventhough it is not required(For ejb3 LocalHome is junk file but it is useful when called from ejb2)
            3. In ejb-jar.xml under <message-driven > element declared the ejb3.0 like below

            <ejb-local-ref >

            4. In jboss.xml under <message-driven> element declared the ejb3.0 like below

            <ejb-local-ref >
            </ejb-local-ref >

            5. In MDB(In my case I need the AuditService in MDB) look up the ejb like following and use
                  auditServiceLocalHome = (AuditServiceLocalHome)ctx.lookup("java:comp/env/ejb/AuditService");
                  auditServiceLocal = (AuditServiceLocal)auditServiceLocalHome.create();
            6. Changed the build file to include in EAR the above XML files instead of the files that got generated using Xdoclets
            7. For the verification purpose go to jmx-console (jboss:service=JNDIView) and check AuditService is visible in java:comp as well as in Global JNDI Namespace

            java:comp namespace of the ReceiverMDB bean:
               +- env (class: org.jnp.interfaces.NamingContext)
               |   +- ejb (class: org.jnp.interfaces.NamingContext)
               |   |   +- AuditService[link -> AuditService/localHome] (class: javax.naming.LinkRef)
            Global JNDI Namespace
              +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
              +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
              +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
              +- AuditService (class: org.jnp.interfaces.NamingContext)
              |   +- localHome (proxy: $Proxy80 implements interface com.receiver.audit.AuditServiceLocalHome)