WL12c : CDI in complex ear deployment does not work

bergler
    I'm migrating a JEE6 application from JBoss7 to WL12c (12.1.1.0) and getting the impression that CDI does not really work in combination wit WLs class loading.
    Yes, I installed patch 13603813 and got rid of some issues, but some annoying problems remain.

    In my scenario I have an .ear-deploment containing a collection of moduls (wars and ejb jars) and some shared library jars in lib/, which are adressed via MANIFEST classpathes.
    The library jars contain CDI beans (yes, META-INF/beans.xml are provided), which are injected into the modules (META-INF/beans.xml at the appropriate places)

    No matter what I do, Im getting org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies, though there is only one possible dependency.
    Example

    WELD-001409 Ambiguous dependencies for type [Lib1Class1] with qualifiers [@Default] at injection point [[field] @Inject private cditest.web.Access.lib1Class1]. Possible dependencies [[Managed Bean [class cditest.lib1.Lib1Class1] with qualifiers [@Any @Default], Managed Bean [class cditest.lib1.Lib1Class1] with qualifiers [@Any @Default]]]

    I've tried the following so far:
    - put the library jars in APP-INF/lib to bring them into the application class loader. Failed: It seems that its not possible to have bean archives in APP-INF/lib. Can't blame oracle for this, its a non-standard extension anyway.
    - combining the module classloaders with weblogic-application.xml <classloader-structure>. Didn't change anything. That caught me by surprise.

    I have condensed my problem tio a minimal project reproducing the bug. It seems that you need at least two ejb-jars, one war and one library jar containing one web bean, which is injected into the war and into one of the ejb-jars.

    Sombody else having this problem? Suggestions?

    If you're interested I can provide a minimal maven project . Any help is appreciated.

    regards
    roland

    weblogic.management.DeploymentException:
         at weblogic.application.internal.BaseDeployment.throwAppException(BaseDeployment.java:123)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:239)
         at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
    ...
    Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [Lib1Class1] with qualifiers [@Default] at injection point [[field] @Inject private cditest.web.Access.lib1Class1]. Possible dependencies [[Managed Bean [class cditest.lib1.Lib1Class1] with qualifiers [@Any @Default], Managed Bean [class cditest.lib1.Lib1Class1] with qualifiers [@Any @Default]]]
         at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:261)
         at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:105)
         at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:125)
         at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:324)
         at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:309)
         at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:361)
         at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:105)
         at com.oracle.injection.integration.CDIAppDeploymentExtension.prepare(Unknown Source)
         at weblogic.application.internal.flow.AppDeploymentExtensionFlow.prepare(AppDeploymentExtensionFlow.java:23)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
         at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    >
      • 1. Re: WL12c : CDI in complex ear deployment does not work
        User696-Oracle
        n my scenario I have an .ear-deploment containing a collection of moduls (wars and ejb jars) and some shared library jars in lib/, which are adressed via MANIFEST classpathes.
        The library jars contain CDI beans (yes, META-INF/beans.xml are provided), which are injected into the modules (META-INF/beans.xml at the appropriate places)

        Since you already have the CDI bean inside library jars in lib/ can please remove the manifest entries of these jar files and test them, this might be duplication which is causing this issue.

        Regards,
        Sunil P
        • 2. Re: WL12c : CDI in complex ear deployment does not work
          bergler
          Since you already have the CDI bean inside library jars in lib/ can please remove the manifest entries of these jar files and test them, this might be duplication which is causing this issue.
          This leads to " WELD-001408 Unsatisfied dependencies", which I expected, as the injected class now is not on the classpath anymore.
          • 3. Re: WL12c : CDI in complex ear deployment does not work
            User696-Oracle
            So is your CDI beans inside
            earfile/lib/<jar files>?

            Can you show the deployment structure of your app. Is your application is exploded format or archive format?

            Regards,
            Sunil P
            • 4. Re: WL12c : CDI in complex ear deployment does not work
              bergler
              Structure is as follows:
              TestApp.ear (archive format)
              +-ejb1.jar
              +-ejb2.jar
              +-web.war
              +-lib
                +-lib.jar
              +-META-INF
                +-application.xml
              The CDI bean is contained in lib.jar (Just a simple un-annotated POJO)

              ejb1.jar and web.war depend on lib.jar for the data type. Both contain a @Inject -annotation on one member of one class each
              ejb2.jar does not have any dependency and contains no @Inject

              /roland

              Edited by: 981275 on Jan 11, 2013 2:45 PM
              • 5. Re: WL12c : CDI in complex ear deployment does not work
                User696-Oracle
                please test with below patch from 13945990
                SmartUpdate-ID_PW - WLS 12.1.1 Patch ID : 27QT

                THis should resolve the issue.

                Regards,
                Sunil P
                • 6. Re: WL12c : CDI in complex ear deployment does not work
                  bergler
                  No, tried it (had to uninstall some other patch 53JP first), but still see the same effects.

                  Edited by: montanero on Jan 14, 2013 4:25 PM
                  • 7. Re: WL12c : CDI in complex ear deployment does not work
                    bergler
                    OK, how do I file a bug report? Is there an issue tracker? Or do I have to go through "service requests"?
                    • 8. Re: WL12c : CDI in complex ear deployment does not work
                      985771
                      Have you tried putting all non-ejb jars in earfile/lib and remove all explicit Classpath references from the manifest files?

                      Regards,
                      Geert
                      • 9. Re: WL12c : CDI in complex ear deployment does not work
                        bergler
                        The jar files in lib/ don't have MANIFET claspath entries.
                        If I remove the Clapath-Entries in the ejb-jar and war Manifests I get "WELD-001408 Unsatisfied dependencies" for the injection points in those modules. Which seems logigical to me.
                        • 10. Re: WL12c : CDI in complex ear deployment does not work
                          985771
                          That is not logical because all jars in the lib directory are available to all modules in the application.
                          This approach together with path BUG13893259_1211 solved the problem for me.
                          • 11. Re: WL12c : CDI in complex ear deployment does not work
                            bergler
                            That is not logical because all jars in the lib directory are available to all modules in the application.
                            You are right, but the other approach is not illegal either: Chapter EE.8.2.1 of the "Java™ Platform, Enterprise Edition (Java EE) Specification, v6" states:
                            Libraries bundled with an application may be referenced in the following ways
                            1. A JAR format file (such as a .jar file, .war file, or .rar file) may reference a .jar file or directory by naming the referenced .jar file or directory in a Class-Path header in the referencing JAR file’s Manifest file.
                            I'll give it another try later today using the patch you mentioned

                            regards
                            /roland
                            • 12. Re: WL12c : CDI in complex ear deployment does not work
                              bergler
                              Tried your bug number and retrieved the containing patch, installed it, started deployment (no classpath entries) and::::
                              Didn't work - again. WELD-001408 Unsatisfied dependencies

                              Thanks for trying
                              /roland
                              • 13. Re: WL12c : CDI in complex ear deployment does not work
                                985771
                                Hi Roland,

                                The error message clearly says that there are 2 identical classes with identical qualifiers valid for injection.
                                This means that either:
                                - the class file is available in different modules. for example in modulex.jar and moduley.war
                                - the class is packaged in one module but available in multiple locations: for example in web-inf/lib/modulex.jar and app-inf/lib/modulex.jar
                                - the class is packaged in one module and the module is only in a single location but there are multiple references to the same module via manifest files, applicaiton.xml file, ...

                                The first two cases are easy to check unless it is a very complex project.

                                The third case can be figured out by debugging the method com.oracle.injection.integration.CDIAppDeploymentExtension.processLibArchives(ApplicationContextInternal, InjectionContainer)
                                This method takes the application classloader and tries to find all locations containing "META-INF/beans.xml".
                                By debugging the method you should get a clear view why your jar or class is picked up more than once.

                                The class CDIAppDeploymentExtension is located in BUG13893259_1221.jar

                                Best regards,
                                Geert
                                • 14. Re: WL12c : CDI in complex ear deployment does not work
                                  985771
                                  That is strange. It should be able to find them.

                                  Does your application.xml contain <library-directory>lib</library-directory>?
                                  See http://docs.oracle.com/cd/E24329_01/web.1211/e24368/libraries.htm#autoId2

                                  Do all modules have JEE 6 compliant xml headers in their descriptor files? (application.xml, web.xml, ...)

                                  Regards,
                                  Geert
                                  1 2 上一个 下一个