JSF Deploy Exception: Unsatisfied dependencies for type EntityManager
inject, jakarta-ee, jboss, jsf, maven
Solution
The `EntityManager` is found in an artifact for which CDI is not enabled (JPA provider jars do not have a `beans.xml` included).
You can either use the "good old" `@PersistenceContext` annotation insead of `@Inject`, or if you want to use `@Inject`, you will need to provide a producer for the EntityManager like this:
class Resources {
@SuppressWarnings("unused")
@Produces
@PersistenceContext
private EntityManager em;
...
Problem
I just followed the ticket-monster tutorial(http://www.jboss.org/jdf/examples/ticket-monster/tutorial/Introduction/) and added a rest-service class to my solution. ``` package projectFoo.rest; import java.util.List; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.persistence.EntityManager; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import projectFoo.model.party; @Path("/partys") @RequestScoped public class partyService { @Inject private EntityManager em; @GET @Produces(MediaType.APPLICATION_JSON) public List<party> getAllEvents() { @SuppressWarnings("unchecked") final List<party> results = em.createQuery( "select e from party e order by e.name").getResultList(); return results; } } ``` @Inject is underlined, returning: "No bean is eligible for injection to the injection point [JSR-299 §5.2.1]" When I try to deploy the package, the process will fail and return the following message: ``` Unsatisfied dependencies for type [EntityManager] with qualifiers [@Default] at injection point. ``` Do I have to add a bean for the Entity Manager? How should this one look like? The tutorial doesn't mention this. Actually I couldn't find any definition of beans in the final ticket-monster project.