0 Replies Latest reply on Apr 27, 2012 6:27 AM by Karsten Wutzke

    Solder @Inject @Exact dependency injection: deployment fails with "Unsatisfied dependencies for type" on @Stateful CDI/EJB

    Karsten Wutzke Expert

      Hello,

       

      I've posted this on SO recently (full code there): http://stackoverflow.com/questions/10346285/unsatisfied-dependencies-for-type-with-qualifiers-default-at-injection

       

      Now I'm trying to inject a CDI bean like:

      {code}@Inject

      @Exact(UserRepository.class)

      private UserRepository userRepo;

      //private CachingRepository userRepo;

      {code}

       

      This seems to work, but when making UserRepository an EJB with @Stateful

      {code}

      @Named("userRepo")

      @SessionScoped

      @Stateful

      public class UserRepository implements CachingRepository, Serializable

      {

          ...

      {code}

       

      deployment fails with:

      {code}Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UserRepository] with qualifiers [@Default] at injection point [[field] @Inject @Exact private de.company.project.pack.MyHandler.userRepo]

          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:275)

          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:244)

          at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:107)

          at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:127)

          at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:346)

          at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:331)

          at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)

          at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)

          at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)

          ... 5 more{code}

       

      Note, that I took the idea of mixing of mixing @Named + @SessionScoped + @Stateful from "Core JavaServer Faces", 3rd ed., p. 517, section "Stateful Session Beans [CDI]" where it sounded like a proposed "superior" pattern:

       

      Quote: "With CDI, your application can be composed of stateful session beans and entity beans, both managed by the EJB container. The JSF pages reference stateful session beans directly. Then the issue of detached entities goes away, and it becomes very simple to access the database from your web application."

       

      This can be argued about, but I don't see what speaks against using it. This will shortly be discussed in another forum, but for now, I'm just wondering why the injection via @Inject + @Exact is failing.

       

      So, why isn't it working as expected?

       

      Thanks

      Karsten