Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.6
    • Fix Version/s: 2.10
    • Component/s: containers
    • Labels:
      None
    • Environment:

      Tomcat 7, Jersey 2.6, Apache Deltaspike 0.5, Weld 2.1.1

      Description

      Deploying jersey 2.6 along with deltaspike 0.5 brings the following error

      Exception 0 :
      org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type MessageInterpolator with qualifiers @Default
        at injection point [BackedAnnotatedField] @Inject @Typed private org.apache.deltaspike.core.impl.message.DefaultMessageContext.messageInterpolator
        at org.apache.deltaspike.core.impl.message.DefaultMessageContext.messageInterpolator(DefaultMessageContext.java:0)
        Possible dependencies: 
        - org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$Hk2Bean@3b2f1ce2,
        - Managed Bean [class org.apache.deltaspike.core.impl.message.DefaultMessageInterpolator] with qualifiers [@Any @Default]
      
      	at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:376)
      	at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:289)
      	at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:135)
      	at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:166)
      	at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:514)
      	at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
      	at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
      	at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
      	at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      	at java.lang.Thread.run(Thread.java:662)
      

      as a quick fix, to enable my app to start, I patched the gf-cdi to not wrap the deltaspike beans, same as it does for java types.
      Is it because deltaspike is an extension ? (so far no issues detected with other dependencies managed beans).

      --- a/containers/glassfish/jersey-gf-cdi/src/main/java/org/glassfish/jersey/gf/cdi/internal/CdiComponentProvider.java
      +++ b/containers/glassfish/jersey-gf-cdi/src/main/java/org/glassfish/jersey/gf/cdi/internal/CdiComponentProvider.java
      @@ -523,7 +523,7 @@ public class CdiComponentProvider implements ComponentProvider, Extension {
           private void afterDiscoveryObserver(@Observes AfterBeanDiscovery abd) {
               potentionalHk2CustomBoundTypes.removeAll(typesSeenBeforeValidation);
               for (Type t : potentionalHk2CustomBoundTypes) {
      -            if (!isJavaxEType(t)) { // need to avoid built-in beans conflict
      +            if (!isJavaxEType(t) && !isDeltaSpikeType(t)) { // need to avoid built-in beans conflict
                       hk2ProvidedTypes.add(t);
                   }
               }
      @@ -542,6 +542,16 @@ public class CdiComponentProvider implements ComponentProvider, Extension {
               return pkgName.startsWith("java.") || pkgName.startsWith("javax.");
           }
       
      +    private boolean isDeltaSpikeType(Type t) {
      +       if (!(t instanceof Class)) {
      +               return false;
      +       }
      +
      +       final String pkgName = ((Class<?>)t).getPackage().getName();
      +
      +       return pkgName.startsWith("org.apache.deltaspike");
      +    }
      +
           private <T> void addInjecteeToSkip(final Class<?> componentClass, final Map<Class<?>, Set<T>> toSkip, final T member) {
               if (!toSkip.containsKey(componentClass)) {
                   toSkip.put(componentClass, new HashSet<T>());
      
      

      The real fix probably ought to be more subtle.

        Activity

        Hide
        Michal Gajdos added a comment -

        Workaround: Try to add deltaspike to the system class-path of Tomcat. This way you should avoid the issue (CDI won't handle classes in the lib as CDI beans).

        Targeting for backlog.
        We should come up with a more generic solution, i.e. allow users list packages that shouldn't be considered for CDI injection.

        Show
        Michal Gajdos added a comment - Workaround: Try to add deltaspike to the system class-path of Tomcat. This way you should avoid the issue (CDI won't handle classes in the lib as CDI beans). Targeting for backlog. We should come up with a more generic solution, i.e. allow users list packages that shouldn't be considered for CDI injection.
        Hide
        jasonzhang2002gmailcom added a comment -

        Got the same issue.

        Show
        jasonzhang2002gmailcom added a comment - Got the same issue.
        Hide
        jasonzhang2002gmailcom added a comment -

        a patch to work around deltaspike would be nice

        Show
        jasonzhang2002gmailcom added a comment - a patch to work around deltaspike would be nice
        Hide
        Jakub Podlesak added a comment -

        This has been fixed in the master branch, to confirm please wait couple of hours for 2.9.1 to appear in the central maven repository,
        where this should be fixed already.

        Show
        Jakub Podlesak added a comment - This has been fixed in the master branch, to confirm please wait couple of hours for 2.9.1 to appear in the central maven repository, where this should be fixed already.

          People

          • Assignee:
            Jakub Podlesak
            Reporter:
            SLx
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: