3 Replies Latest reply on Mar 23, 2012 6:09 PM by ctomc

    as7 modules and cdi problem

    herb

      I've a my.jar which contains cdi beans and cdi producer methods and a META-INF/beans.xml file.

      Putting this jar to WEB-INF/lib in my war, the web app can use the cdi producer methods of my.jar.

       

      Then I moved my.jar from WEB-INF/lib to a AS7 module and I added a dependency in the war's MANIFEST.MF:

      Dependencies: com.mycompany

       

      But now as7 reports

           org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [BeanXY] with qualifiers [@Default] at injection point [[field] @Inject

      It seams that weld does not scan my.jar which is loaded as as7 module. (instantiating BeanXY directly ("new BeanXY()")  works - so the module is loaded correctly)

       

      Is there a limitiation that prevents the use of cdi in conjunction with as7 module?

      Or is there an option to set?

      Or ...?

        • 1. Re: as7 modules and cdi problem
          ctomc

          Hi,

           

          by default all modules won't expose annotations.

          to asure this, you have to explitly create jandex index of annotations and put it into your jar or pack it seperatly.

          for more on how to do this take a look at jandex https://github.com/jbossas/jandex  (there is also ant target to do that)

           

          after you have created this index and put it into your jar or as extra resource to your modle.

          you have to explisitly import annotations, so in your case you need in manifest entry like this:

           

          Dependencies: com.mycompany annotations

           

          hope it helps,

          --

          tomaz

          • 2. Re: as7 modules and cdi problem
            herb

            Thank you for your reply - but it does not work for me

             

            Maybe I missing something:

            • I created a jandex.jar: <jandex run="true" newjar="true"><fileset dir="${deploy.dir}"/></jandex>
            • I put "my.jar" and "my-jandex.jar" to modules directory
            • I additionally added <resource-root path="my-jandex.jar"/> to module.xml
            • I modified MANIFEST.MF dependencies: "Dependencies: mymodule export annotations" (I also tried without "export")

             

            But I still get the above "WELD-001408 Unsatisfied dependencies"

             

            Any suggestions?

             

            herb

            • 3. Re: as7 modules and cdi problem
              ctomc

              hi,

               

              this should work, the only thing looking fishy is the jandex task, that <fileset dir="${deploy.dir}" there should be just your jar file and nothing else

               

              you can run jandex manualy in command line

              by running java -jar jandex.jar and it will give you all options, but in general you need just to create index for your jar file that has annotations.

               

               

              --

              tomaz