7 Replies Latest reply on Mar 15, 2013 3:01 AM by benjaminprevot

    CDI producer in module

    benjaminprevot

      Hello,

       

      I am testing JBoss EAP 6.1.0.Alpha (on Windows 7 with JDK 1.6.0_24).

       

      In particular, I would like to have CDI producer in module.

       

      I have found this issue : https://issues.jboss.org/browse/AS7-4567

       

      It seems this feature is available in this version.

       

      But I cannot get it work and still get the exception WELD-001408 Unsatisfied dependencies for type...

       

      I have tested with an EAR containing a single EJB library (for Web Service).

       

      The module is correctly defined as the classes are found (and I declared it as global module in my standalone.xml file).

       

      I have added the Dependencies attribute in the MANIFEST.MF file and added jboss-deployment-structure.xml in META-INF.

       

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure>

          <deployment>

              <dependencies>

                  <module name="my.module" />

              </dependencies>

          </deployment>

      </jboss-deployment-structure>

       

      Is there some other configuration?

       

      Thanks

        • 1. Re: CDI producer in module
          ctomc

          Hi,

           

          how did you prepare module?

           

          does it contain jandex index?

           

           

          --

          tomaz

          • 2. Re: CDI producer in module
            benjaminprevot

            Hi,

             

            The module is a simple JAR copied in the %JBOSS_EAP%/modules/system/layers/base/my/test/main folder with a module.xml file.

             

            What is a jandex index ?

             

            If you mean the .jar.index file, yes, the file is in the module folder.

             

            I have attached a sample.

            • 3. Re: CDI producer in module
              brian.stansberry

              Two suggestions regarding module placement:

               

              1) Don't put it in modules/system/layers/base, as that is for modules that ship with EAP. End user-provided modules can remain simply under modules/.

               

              2) The string format for the id of a module is dot.separated.name[:slot]. The :slot part is optional in the string form, with a default 'slot' of "main" assumed if not provided. However, the filesystem path to the root of the module requires the full name and slot. So, the path to the root of your module would be %JBOSS_EAP%/modules/my/test/main.

              1 of 1 people found this helpful
              • 4. Re: CDI producer in module
                brian.stansberry

                Note that putting it under modules/system/layers/base wouldn't prevent it working; it's just not the intended way to do it. The key part is including "main" in the filesystem path.

                • 5. Re: CDI producer in module
                  benjaminprevot

                  Hello Brian,

                   

                  I forgot to copy/paste the main folder for the module.

                   

                  In fact, it exists (I have updated my message).

                   

                  I have tested with the module directly deployed in modules (%JBOSS_EAP%/modules/my/test/main) but same result

                  • 6. Re: CDI producer in module
                    brian.stansberry

                    I'm not an expert in this particular feature, but your module packaging sounds fine. You describe adding Dependencies to MANIFEST.MF as well.

                     

                    Here's a link to a test case that was added as part of the commit for AS7-4567. Perhaps you'll notice a difference between what's done there and what you're doing. The deploy2() method is what creates the test deployment. It builds a jar (using shrinkwrap but that's irrelevant) that packages up the deployment's classes, beans.xml and a MANIFEST.MF with contents "Dependencies: org.jboss.test.weldModule meta-inf".

                    • 7. Re: CDI producer in module
                      benjaminprevot

                      Brian, you're the best

                       

                      I didn't noticed the meta-inf information in the Dependencies attribute when looking for a solution.

                       

                      That's the key.

                       

                      I have added it, and it works fine.

                       

                      To sum up, here is the configuration:

                       

                      Module

                      1. Create a module with CDI producer
                      2. Add META-INF/beans.xml file in it
                      3. Deploy it in %JBOSS_EAP%/modules/my/module/main with the module.xml file

                       

                      Application

                      1. Add Dependencies: my.module meta-inf in MANIFEST.MF
                      2. Deploy in JBoss EAP
                      3. Run

                       

                      Thanks a lot for your help.