Hello, I'm evaluating now SEAM framework as new Web development framework for our project. I have some poblems using it.
I took the Logout stateful session bean as in booking example and separated the db calls outside the ejb:
public class ChangePasswordAction implements ChangePassword { @In(create=true) ChangePwdDao changePwdDao; public String changePassword() { if ( changePwdDao.changePassword()) { FacesMessages.instance().add("Password updated"); return "main"; } else { FacesMessages.instance().add("verify", "Re-enter new password"); changePwdDao.cancel(); return null; } }
@Scope(EVENT) @Name("changePwdDao") public class ChangePwdDao { @In @Out private User user; @PersistenceContext private EntityManager em; public boolean changePassword() { //using em here }
Container-managed persistence contexts (ie. @PersistenceContext) only work in EJBs. Your DAO is not an EJB, so you must use a Seam-managed persistence context.