Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2143

Same CDI extension in multiple wars in ear only loaded once


    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.2.14.Final, 2.3.2.Final
    • Fix Version/s: 2.3.5.Final, 3.0.0.Alpha17
    • Component/s: Extensions
    • Labels:
    • Environment:

      WildFly 10.0.0 and 9.0.2


      When multiple wars, in the same ear, share a library with a CDI extension, the CDI extension is only loaded for 1 of the wars. If, for example, this CDI extension registers a bean, this bean is only available in one of the wars, resulting in an unsatisfied dependency.

      I've attached a demo-project, with 4 modules:

      • a shared lib with a CDI extension
      • 2 (almost) identical wars
      • an ear, containing both wars

      The wars, when deployed directly, function fine. However, when deployed together in the ear, you get the following exception:

      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type TestBean with qualifiers @Default
        at injection point [BackedAnnotatedField] @Inject private nl.topicus.TestServlet2.testBean
        at nl.topicus.TestServlet2.testBean(TestServlet2.java:0)

      The exception is triggered in TestServlet1 or TestServlet2, depending on the order of initialization.

      As war1 and war2 use different classloaders for loading TestExtension, I expect the extension to load for both wars, with a different instance of 'TestBean'. Stepping through the code, I noticed that the extension is instantiated and registered twice, however AfterBeanDiscovery only fires on one of the two. This seems to be caused by org.jboss.weld.resolution.TypeSafeResolver.findMatching overwriting the first extension by the second in 'result'. ExtensionObserverMethodImpl implements equals and hashCode via its id, which contain no information about the BeanManager.

        Gliffy Diagrams




              • Assignee:
                mkouba Martin Kouba
                papegaaij Emond Papegaaij
              • Votes:
                0 Vote for this issue
                3 Start watching this issue


                • Created: