Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-1662

Incorrect resolution of managed bean alternatives for

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Rejected
    • 7.0.1.Final
    • 7.0.1.Final
    • CDI / Weld
    • None
    • Hide

      Please see description.

      Show
      Please see description.

    Description

      Given a JEE EAR project Test that includes a WAR project TestWeb which references a Java project TestCommon as a deployment assembly.

      In the TestCommon project I have a managed bean named TestService annotated with the @ApplicationScope and @Alternative annotations that implements the interface ITestService. In the TestCommon project I have another managed bean named AnotherTestService that injects the TestService implementation using an @Inject annotation on a private variable of type ITestService.

      In the TestWeb application I have a servlet which injects the TestService implementation using an @Inject annotation on a private variable of type ITestService.

      I have added a beans.xml file to my WEB-INF folder for the TestWeb WAR and declared the TestService class as an alternative.

      I attempted to add a beans.xml file to the META-INF folder under the TestCommon project without any alternative classes specified.

      When I attempt to deploy my application on JBoss 7.0.1 I receive the error "WELD-001408 Unsatisfied dependencies for type [ITestService] with qualifiers [@Default] at injection point [[field] @Inject private absa.test.model.AnotherTestService.testService]".

      It appears that Weld is not using the alternative specified in the WEB-INF/beans.xml file that forms part of the TestWeb WAR. Instead Weld is trying to resolve the alternative only using the META-INF/beans.xml file that forms part of the TestCommon JAR.

      If I add the TestService class as an alternative to the META-INF/beans.xml file that forms part of the TestCommon JAR then the application deploys successfully.

      If I add another alternative implementation for the ITestService interface to the TestCommon JAR project and reference this alternative in the WEB-INF/beans.xml file that forms part of the TestWeb WAR then the servlet is injected with this new implementation. The AnotherTestService though is still injected with the alternative specified in the META-INF/beans.xml file for the TestCommon JAR.

      It appears as if Weld is not overriding the alternative specified in the META-INF/beans.xml file for the TestCommon JAR with the alternative specified in the WEB-INF/beans.xml file that forms part of the TestWeb WAR.

      Attachments

        Activity

          People

            sdouglas1@redhat.com Stuart Douglas
            marcusportmann Marcus Portmann (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: