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.
Seems like DAOTest's archive has no beans.xml / misplaced beans.xml.
@LocalBean means you will inject the bean and not the interface
@Inject Service service
and not
@Inject ServiceLocal service
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.
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.