5 Replies Latest reply on Sep 13, 2013 11:35 AM by slrslr

    EJB injection from JBoss Module

    slrslr Newbie



      I am using wildfly alpha 4.


      I have the following deployment:

      - an EAR A.ear embedding a servlet "servlet.war" and an ejb "ejb.jar"

      - a Jboss module with a jar "ejb-client.jar". It is a Jboss modules because it is used/shared by numerous deployments.


      When accessed, my servlet calls a class inside the jboss module "ejb-client.jar" which should call the local ejb located inside "ejb.jar"


      The problem is that in my Jboss module, the annotation "@EJB" is completely ignored and no injection/EJB call is performed.

      If I put my "ejb-client.jar" inside the lib folder of the EAR it works correctly, i.e. the local EJB is called.


      So questions:

      - Am I missing something to have the annotations processed ? I tried to put "annotations=true" in the jboss-deployment-structure.xml of the EAR and I include "javaee.api" in the dependencies of my module that normally resolves all the javax imports, including the one for the annotations.


      - Or is it a known behaviour that the EJB annotations are not working in JBoss modules. From my understanding, as the modules are loaded at deployment of the EAR, they belong to a JEE container and should have no problem to use JEE features.


      P.S.: I have absolutely no error at deployment or transaction time, only the "EJB object" on client side that remains null and no trace of trying to access the EJB.


      Thank you in advance.


        • 1. Re: EJB injection from JBoss Module
          Wolf-Dieter Fink Master

          I think you mean this feature WFLY-2030?

          You might use upstream to check it.

          • 2. Re: EJB injection from JBoss Module
            Tomaz Cerar Master

            Did you create jandex annotation index for your ejb jboss module?

            • 3. Re: EJB injection from JBoss Module
              slrslr Newbie



              No I did no create a jandex index.

              I have already seen this word when searching info about my problem, but I never managed to find any documentation about what is jandex index (except that it is an index of annotations present in a jar), what it does and in which case and how to use it.


              Is it necessary ? If yes how does it work ?


              Thank you.

              • 4. Re: EJB injection from JBoss Module
                jaikiran pai Master

                See this thread Annotation inheritance on AS 7 and the ones referenced in there.

                1 of 1 people found this helpful
                • 5. Re: EJB injection from JBoss Module
                  slrslr Newbie



                  This is what I tried:

                  - generate the jandex index file for the jar file that have indexes in my module (I never managed to generate an index file for the whole directory).

                  - I created a jar called jandex.jar with a folder META-INF and inside the jandex.idx that I just generated.

                  - I updated the module.xml and added this jandex.jar in the resources-root.


                  When loading the module I see:

                  17:24:17,614 TRACE [org.jboss.modules] (MSC service thread 1-2) Attempting to find all resources META-INF/jandex.idx in Module <name_of_my_module>:main" from local module loader @215750e4 (finder: local module finder @6b7fb9d5 (roots: /<my_install>/JBoss/modules, <my_install>/JBoss/modules/system/layers/base))

                  17:24:17,614 ERROR [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015894: Module <name_of_my_module>:main will not have it's annotations processed as no META-INF/jandex.idx file was found in the deployment. Please generate this file using the Jandex ant task.


                  So it does not find the jandex.idx.

                  I also tried:

                  - put the jandex.idx in my original jar (here also the -m option does not work, so I unjared added the file, and repacked manually) --> not better

                  - I then thought that it was because the META-INF folders of a module are not loaded by default in a deployment. I tried to add an <imports> block in the jboss_deployment_structure.xml to tell it to import "META-INF/*" --> not better


                  I also tried to find an example working, it seems that the resteasy jars (as sugggested in one link) do not have jandex.idx files anymore.


                  What is the recipe ? I am not sure of anything I do cause there is no documentation anywhere. Is there something special to do to have the jandex.idx found (special location) and processed at deployment time ?


                  Thank you in advance