@PersistenceContext in JSF managed bean--how?
The blog says that the JSF spec has been updated--you can now use @PersistenceContext in a JSF bean. The blog also says that this is fully implemented in b37.
I tried it, and I got this error message:
javax.servlet.ServletException: Unable to retrieve EntityManagerFactory for unitName defaultPersistenceUnit
Actually, I was curious how this would work. A JSF managed bean does not live inside the EJB container, right? So I tried the approach outlined in https://glassfish.dev.java.net/javaee5/persistence/persistence-example.html and used @PersistenceContext instead. Same error.
Ok, maybe it can't find persistence.xml? Here I am getting fuzzy on the deployment rules. I deploy an ear file that contains an ejb.jar file and a web.war file. I guess the JSF stuff inside web.war can't find ejb.jar. (Well, that can't quite be the answer--the same setup is perfectly willing to inject sessions beans into JSF manageed beans.)
I am left with two questions. (1) Can I really use the entity manager in JSF managed beans and bypass session beans altogether? (2) How should I organize my deployment archive?