@PersistenceContext cannot be resolved to a type

Posted by Saken Kungozhin on Stack Overflow See other posts from Stack Overflow or by Saken Kungozhin
Published on 2012-10-13T09:33:23Z Indexed on 2012/10/13 9:36 UTC
Read the original article Hit count: 221

i was running a code in which there's a dependency @PersistenceContext and field private EntityManager em; both of which cannot be resolved to a type, what is the meaning of this error and how can i fix it? the code is here:

package org.jboss.tools.examples.util;

import java.util.logging.Logger;`

import javax.enterprise.context.RequestScoped; import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.InjectionPoint; import javax.faces.context.FacesContext;

/** * This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans * * <p> * Example injection on a managed bean field: * </p> * * <pre> * &#064;Inject * private EntityManager em; * </pre> */ public class Resources { // use @SuppressWarnings to tell IDE to ignore warnings about field not being referenced directly @SuppressWarnings("unused") @Produces @PersistenceContext private EntityManager em;

@Produces public Logger produceLog(InjectionPoint injectionPoint) { return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); }

@Produces @RequestScoped public FacesContext produceFacesContext() { return FacesContext.getCurrentInstance(); } }

© Stack Overflow or respective owner

Related posts about dependency-injection

Related posts about annotations