5 Replies Latest reply on Aug 24, 2012 9:45 AM by lehvolk

    Processing of EJB annotations in module

    lehvolk

      Hi to all.

       

      Currently I migrate my applications from JBoss 5.1 to JBoss 7.1. On 5.1 I had five ear applications with number of common libs (placed in default/lib folder). This libraries in JBoss 7.1 I place in special module (which used as global module). This libraries have common classes and interfaces for all applications (such as management interfaces, base classes etc). But seems that server not processed EJB annotations from classes in modules. For example:

       

      this class places in module:

       

      {code}

      public BaseEJBBean {

       

           @Resource

           private TimerService timerService;

      ....

      }

      {code}

       

       

      And when server create instance of bean from ear:

       

      {code}

      @Stateless

      public EJBBean extends BaseEJBBean {

       

      ....

      }

      {code}

       

      TimerService not injected by container (also @PostConstruct annotations ignored, but as I think this is weld issue). If I place jar with BaseEJBBean inside ear then all work fine. Also I had the same problem with cxf interfaces and annotaions, but this problem fixed by adding few dependencies to module (solution was found into this disscussion https://community.jboss.org/thread/201304). Is there any way to make jboss process EJB annotations from module (maybe just by adding some dependencies)?

        • 1. Re: Processing of EJB annotations in module
          jaikiran

          What does your jboss-deployment-structure.xml look like?

          • 2. Re: Processing of EJB annotations in module
            lehvolk

            I don't use jboss-deployment-structure.xml. I create apps.common module with dependencies:

             

            {code}

            <dependencies>

                 <!-- some libs -->

                 <module name="apps.deploylibs" export="true"/>

             

                 <module name="com.microsoft.mssql" export="true"/>

                 <module name="com.sun.xml.bind" export="true"/>

                 <!-- cxf libs -->

                 <module name="org.apache.cxf" export="true"/>

             

                 <module name="javax.servlet.api" />

                 <module name="javax.jms.api" />

                 <module name="javax.ejb.api" />

                 <module name="javax.transaction.api" />

                 <module name="javax.enterprise.api" />

                 <module name="javax.xml.bind.api" />

             

                  <!-- this libs to process cxf annotations -->

                  <module name="javax.xml.ws.api" />

                  <module name="javax.jws.api" export="true"/>

                  <module name="javax.wsdl4j.api" export="true"/>

             

                 <module name="org.jboss.logging"/>

                 <module name="org.apache.log4j" />

                 <module name="org.apache.commons.io" export="true"/>

                 <module name="org.apache.commons.codec" export="true"/>

                 <module name="org.apache.commons.lang" export="true"/>

            </dependencies>

            {code}

             

            and declare this module as global (standalone.xml)

            {code}

            <subsystem xmlns="urn:jboss:domain:ee:1.0">

                 <global-modules>

                       <module name="org.apache.commons.beanutils" slot="main"/>

                       <module name="org.apache.commons.collections" slot="main"/>

                       <module name="apps.common" slot="main"/>

                       <module name="com.microsoft.mssql" slot="main"/>

                       <module name="org.quartz" slot="main"/>

                  </global-modules>

            </subsystem>

            {code}

            • 3. Re: Processing of EJB annotations in module
              lehvolk

              I forget to mention dependencies for apps.deploylibs module:

               

              {code}

              <dependencies>

                      <module name="javax.inject.api" export="true"/>

                      <module name="javax.api" export="true"/>

                      <module name="org.apache.commons.logging"/>

                      <module name="org.apache.httpcomponents" export="true"/>

                      <module name="org.antlr" export ="true"/>

                      <module name="org.jaxen"/>

              </dependencies>

              {code}

               

              they will be added to apps.common module.

              • 4. Re: Processing of EJB annotations in module
                robbert1

                I have the exact same problem with base classes coming from other deployments that I import using a jboss-deployment-structure.xml.

                I was about to try to move the base class to my global module (which is to be my end solution) exactly as described above but I guess that doesn't work either...

                 

                I noticed so far @PostConstruct and @Resource not working when a Base class comes from outside of the same deployment.

                 

                ejb-jar using an annotated method from base class from other jar within the same ear --> works

                ejb-jar using an annotated method from base class from other jar within other ear --> fails

                ejb-jar using an annotated method from base class from other jar within global module --> fails

                 

                not sure about ManagedBean's exact behavior yet, however jboss 5.1 failed at that as well so it doesn't break any migration scenario.

                • 5. Re: Processing of EJB annotations in module
                  lehvolk

                  Actually this is not a problem to move jar into ear but I don't get the mechanism of deployer. As I understand deployer should look throught super classes und get all annotated fields. But seems that It isn't true and I don't understand why. In cxf case I can understand problems but in this case I have no idea of this strange behaviour, does anybody have?.