2 Replies Latest reply on Mar 3, 2014 7:39 AM by Martin Kouba

    Is really a @Decorator an injectable managed bean?

    Lucas Ventura Carro Newbie

      I'm new using the @Decorator annotation, and it fits perfect. But I'm facing problemas injecting a bean annotated.

      As CDI-1.1 docs says:

      • It is a concrete class, or is annotated @Decorator.

      So I supposed that my @Decorator bean could be injected as other bean, but it is not working in a Tomcat 6 with weld-servlet-2.1.2.Final. I'm trying to inject the bean in a javax.servlet.Filter, without even using it. While other beans are correctly injected, when I add the injection of the bean I get:

      org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type DecoratedFoo with qualifiers @Default at injection point [BackedAnnotatedField] @Inject private com.foo.FooFilter.foo at com.foo.FooFilter.foo(FooFilter.java:0)

              at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:368)

              ...

       

      These are the three classes (interface, real implementation and decorated implementation)

      public interface FooI {
          String getS();
      }
      

       

      public class ImplementationFoo implements FooI {
          public String getS() {
              return "a";
          }
      }
      

       

      @Decorator
      public class DecoratedFoo implements FooI {
          @Inject
          @Delegate
          private FooI delegate;
      
          public String getS() {
              return delegate.getS() + "b";
          }
      }
      

       

      And the filter only is:

      public class FooFilter implements Filter {
          @Inject
          private DecoratedFoo foo;
          [rest of filter methods]
      }
      

       

      I'm doing something wrong? Is a weld bug? Is a doc bug?