glassfish
  1. glassfish
  2. GLASSFISH-15660

[Regression] Ambiguous dependencies for Session Beans

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1_b38
    • Fix Version/s: None
    • Component/s: cdi
    • Labels:
      None
    • Environment:

      Ubuntu Linux 10.04, JDK 1.6.0_22

      Description

      There seems to be a new bug in the latest version of Weld: Session beans from CDI-enabled EJB JARs are registered twice, both as sessions beans and as managed beans, causing exceptions of the following kind:

      Caused by: org.jboss.weld.exceptions.AmbiguousResolutionException:
      WELD-001318 Cannot resolve an ambiguous dependency between
      [Managed Bean [class com.blogspot.hwellmann.cdi.InjectedService] with qualifiers [@Any @Default],
      Session bean [class com.blogspot.hwellmann.cdi.InjectedService with qualifiers [@Any @Default]; local interfaces are [InjectedService]]

      Simple example to reproduce the problem:

      ------------------

      package com.blogspot.hwellmann.cdi;

      import javax.ejb.Stateless;

      @Stateless
      public class InjectedService {

      public void doSomething()

      { System.out.println("********* injected method *********"); }

      }

      ----------------------

      package com.blogspot.hwellmann.cdi;

      import javax.annotation.PostConstruct;
      import javax.ejb.Singleton;
      import javax.ejb.Startup;
      import javax.inject.Inject;

      @Singleton
      @Startup
      public class ClientService {

      @Inject
      private InjectedService injected;

      @PostConstruct
      public void execute()

      { injected.doSomething(); }

      }

      Build a service.jar with these two classes, adding an empty META-INF/beans.xml.
      Then build an almost empty WAR, containing this service.jar in WEB-INF/lib.

      The WAR fails to deploy with the above exception. The problem does not occur when the two classes are directly in WEB-INF/classes and not in an embedded JAR.

      This is a regression from 3.1-b33 where the same WAR can be deployed successfully.

      1. GLASSFISH-15660.diff
        10 kB
        Sivakumar Thyagarajan

        Issue Links

          Activity

          Hide
          Harald Wellmann added a comment -

          Attached example WAR to reproduce the problem.

          Show
          Harald Wellmann added a comment - Attached example WAR to reproduce the problem.
          Hide
          Sivakumar Thyagarajan added a comment -
          • 3.1 Change Control related questionnaire
          • How bad is its impact? (Severity)
            Is a regression of functionality or performance available in a prior release
          • How often does it happen? (Frequency)
            Rarely
          • How much effort is required to fix it? (Cost)
            Fix available and attached in issue
          • What is the risk of fixing it? (Risk)
            Not significant. I ran CDI devtests, TCK, other test scenarios to ensure that there are no regressions.
          • Does a work around for the issue exist? Can the workaround be reasonably employed by the end user?
            Yes, the application can be re-packaged such that the EJBs are bundled in the WAR instead of the bundled library under WEB-INF/lib
          • If the issue is not fixed should the issue and its workaround (if applicable) be described in the Release Notes?
            Yes.
          Show
          Sivakumar Thyagarajan added a comment - 3.1 Change Control related questionnaire How bad is its impact? (Severity) Is a regression of functionality or performance available in a prior release How often does it happen? (Frequency) Rarely How much effort is required to fix it? (Cost) Fix available and attached in issue What is the risk of fixing it? (Risk) Not significant. I ran CDI devtests, TCK, other test scenarios to ensure that there are no regressions. Does a work around for the issue exist? Can the workaround be reasonably employed by the end user? Yes, the application can be re-packaged such that the EJBs are bundled in the WAR instead of the bundled library under WEB-INF/lib If the issue is not fixed should the issue and its workaround (if applicable) be described in the Release Notes? Yes.
          Hide
          Sivakumar Thyagarajan added a comment -

          Analysis:

          • EJBs bundled within the bundled library in the WAR (jar in WEB-INF/lib) was represented as EJBs of the WAR BDA to Weld. The EJBs were represented as Bean classes in the WEB-INF/lib jar BDA. So, Weld understood the EJB as both a ManagedBean and an EJB, and hence deployment failed with an Ambiguous Resolution exception.

          Fix involved ensuring that the WEB-INF/lib jar BDA has the EJB Class represented as EJBs and the Bean classes of that BDA.

          Show
          Sivakumar Thyagarajan added a comment - Analysis: EJBs bundled within the bundled library in the WAR (jar in WEB-INF/lib) was represented as EJBs of the WAR BDA to Weld. The EJBs were represented as Bean classes in the WEB-INF/lib jar BDA. So, Weld understood the EJB as both a ManagedBean and an EJB, and hence deployment failed with an Ambiguous Resolution exception. Fix involved ensuring that the WEB-INF/lib jar BDA has the EJB Class represented as EJBs and the Bean classes of that BDA.
          Hide
          Sivakumar Thyagarajan added a comment -

          Proposed diff to fix the issue.

          Show
          Sivakumar Thyagarajan added a comment - Proposed diff to fix the issue.
          Hide
          Chris Kasso added a comment -

          Approved for 3.1

          Show
          Chris Kasso added a comment - Approved for 3.1
          Hide
          Harald Wellmann added a comment -

          Thanks for fixing this so quickly! Just a small note on the patch: I don't know about official Glassfish policies, but I'd rather use log.debug() instead of System.out.println(), or simply delete these statments, if they were just intended for testing the fix.

          Show
          Harald Wellmann added a comment - Thanks for fixing this so quickly! Just a small note on the patch: I don't know about official Glassfish policies, but I'd rather use log.debug() instead of System.out.println(), or simply delete these statments, if they were just intended for testing the fix.
          Hide
          Sivakumar Thyagarajan added a comment -

          Harald: Yes the system.outs were just debug statements for testing the fix. I would convert them to property log statements prior to the commit.

          Show
          Sivakumar Thyagarajan added a comment - Harald: Yes the system.outs were just debug statements for testing the fix. I would convert them to property log statements prior to the commit.
          Hide
          Sivakumar Thyagarajan added a comment -

          Fixed as part of
          $ svn commit .
          Sending weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java
          Sending weld-integration/src/main/java/org/glassfish/weld/BeanManagerNamingProxy.java
          Sending weld-integration/src/main/java/org/glassfish/weld/WeldDeployer.java
          Sending weld-integration/src/main/java/org/glassfish/weld/ejb/EjbDescriptorImpl.java
          Sending weld-integration/src/main/java/org/glassfish/weld/services/JCDIServiceImpl.java
          Transmitting file data .....
          Committed revision 44711.

          Show
          Sivakumar Thyagarajan added a comment - Fixed as part of $ svn commit . Sending weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java Sending weld-integration/src/main/java/org/glassfish/weld/BeanManagerNamingProxy.java Sending weld-integration/src/main/java/org/glassfish/weld/WeldDeployer.java Sending weld-integration/src/main/java/org/glassfish/weld/ejb/EjbDescriptorImpl.java Sending weld-integration/src/main/java/org/glassfish/weld/services/JCDIServiceImpl.java Transmitting file data ..... Committed revision 44711.

            People

            • Assignee:
              Sivakumar Thyagarajan
              Reporter:
              Harald Wellmann
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: