CDI : WELD-001408 Unsatisfied dependencies, how to resolve it?

前端 未结 4 1667
一生所求
一生所求 2021-01-01 13:24

I do a small test project with CDI. My application is composed of an EJB EAR and WAR, all deployed on Glassfish 4. I\'m using Hibernate 4.3.4 to access the database.

相关标签:
4条回答
  • 2021-01-01 13:47

    Seems like DAOTest's archive has no beans.xml / misplaced beans.xml.

    0 讨论(0)
  • 2021-01-01 13:53

    @LocalBean means you will inject the bean and not the interface

    @Inject Service service
    

    and not

    @Inject ServiceLocal service
    
    0 讨论(0)
  • 2021-01-01 13:55

    Java EE 7 has implicit bean archives by default, i.e. a bean class requires a scope annotation to be discovered as CDI bean.

    @Named is not a scope annotation. Try @Dependent instead.

    beans.xml is no longer required in CDI 1.1/Java EE 7. If you do have one, then the exact version and the bean-discovery-mode make a difference. See the Bean archives section of the CDI 1.1 spec.

    As you didn't post your beans.xml, it's hard to tell whether or not this file is part of the problem.

    0 讨论(0)
  • 2021-01-01 13:57

    Since this is the first hit I got searching for WELD-001408, let me also mention one cause which is the lack of a no-arg constructor. This was apparently NOT the case for the OP but it was the cause of the problem in my own case, so this may help others too.

    0 讨论(0)
提交回复
热议问题