This content has been marked as final.
Show 3 replies
-
1. Re: EntityManager not being injected
c_eric_ray Aug 21, 2006 4:22 PM (in response to c_eric_ray)Here's the code
jsf code...<h:selectOneMenu value="#{elem.code}" > <f:selectItems value="#{element.codeMap}" /> </h:selectOneMenu>
Converter implementation@PersistenceContext(unitName="DC") EntityManager em; public Object getAsObject(FacesContext fContext, UIComponent component, String value) throws ConverterException { CodeEntity ce = em.find(CodeEntity.class, value); return ce; }
em is always null. How can that be? This class is inside the container. Even if I make it a Session Bean is still doesn't work.
Need ideas. Thanks. -
2. Re: EntityManager not being injected
treespace Aug 23, 2006 12:32 PM (in response to c_eric_ray)The SLSB works and is the logical place to put such code. EM injection will not work just yet -- requires servlet 2.5 compliant container.
Are you sure your persistence.xml is correct for the "DC" unit and that it references a valid datasource? -
3. Re: EntityManager not being injected
c_eric_ray Aug 23, 2006 1:32 PM (in response to c_eric_ray)Yes, the persistence.xml is correct. I use the EM all throughout my code. I understand the problem is related to the Converter implementation class being instiated by JSF and not the EJB container or something like that. Therefore, injection cannot occur.
Are you implying this will be fixed in the 2.5 servlet spec?