5 Replies Latest reply on Apr 22, 2015 4:14 AM by mkouba

    Weld cannot find producer method in library jar

    abhi0123

      Using Wildfly 8.2.0.Final, which I believe uses Weld 2.2, I've reproduced this issue with 2 simple classes in a Maven multimodule project. One produces a javax.ws.rs.client.Client, another has an injection point for the same. Arquillian deployment fails with WELD-001408: unsatisfied dependencies.

      The producer is in a library jar that gets included in the WEB-INF/lib for the consumer. Producer has a beans.xml in the META-INF with discovery-mode=annotation and the consumer has one in WEB-INF with discovery-mode=all.

      This is somewhat related to Re: WELD-001408: Unsatisfied dependencies for type List with qualifiers which was never solved. mkouba

       

      Steps to reproduce:

      Download the attached project and run mvn clean install from the root directory.

       

      This is a critical issue. Created JIRA [WELD-1921] Weld cannot find producer method in library jar - JBoss Issue Tracker

        • 1. Re: Weld cannot find producer method in library jar
          mkouba

          Hi,

          I've tried to reproduce the problem and found out that:

          1. it's not possible to run mvn clean install from the root directory - the directory structure is messed up
          2. the test assertion in ConsumerTest is wrong:
          @Test
          public void testGetClient() {
            // You can't do this to test an injected Consumer instance!
            assertNotNull(new Consumer().getClient());
          }
          

          If I move cdi-consumer and cdi-producer dirs to cdi-producer-consumer and change the assertion to:

          @Test
          public void testGetClient(Consumer consumer) {
            // Let Arquillian to inject an instance from CDI container
            assertNotNull(consumer.getClient());
          }
          

          the test passes. Could you verify my findings?

          • 2. Re: Weld cannot find producer method in library jar
            abhi0123
            1. Correct. The producer and consumer are maven modules and should be inside the parent directory. That's how it is on my local but looks like the export from Eclipse flattened out the structure.
            2. Correct. My bad, using new operator is totally stupid, the container has to instantiate the class. In fact it looks like direct injection of Client in the test class works too.

             

            I created this project to demonstrate the same problem I was having in a larger project. I'll check there as well and see if I'm missing anything. I appreciate how you took the time to deal with the wrong directory structure and then asked for verification. Unfortunately, a more common approach on the forums is "I couldn't reproduce your problem".

             

            P.S: I tried to reply twice earlier but the site was down.

            • 3. Re: Weld cannot find producer method in library jar
              mkouba

              Unfortunately, a more common approach on the forums is "I couldn't reproduce your problem".

              Well, sometimes it is really difficult to reproduce the problem.

               

              I will close WELD-1921. Feel free to reopen it if you find something relevant in the other project.

              • 4. Re: Weld cannot find producer method in library jar
                abhi0123

                mkouba I couldn't reproduce the problem in another project even though I tried for days. So I trimmed down the original project to a similar configuration. I can't for my life see any real difference but the following fails to find producer in a jar. Please prove me wrong and no one else will be happier.

                 

                Steps to reproduce:

                1. git clone https://github.com/abhijitsarkar/java-ee.git
                2. cd hospital-appointment-system.
                3. mvn clean install.

                 

                I'll reopen WELD-1921 too.

                • 5. Re: Weld cannot find producer method in library jar
                  mkouba