While persisting (Transaction) the state of entity in custom JEE5 Application error appears: The class >>******<< is not a valid entity. The application is is based on EJB Java Dictionary Entity for backend, Stateless session Beans for middle tier along with JSF / ManagedBean / JSP front end. Code used to persist the entity is as follows:
private String Error1;
@PersistenceContext
EntityManager em;
@Resource
private UserTransaction utx;
public String Save() throws Exception{
try
{
utx.begin();
Audits ad = new Audits();
ad.setDept("HR");
ad.setRemarks("Remarks");
ad.setPurpose("Purpose");
ad.setAuditno(11);
ad.setCostcenter(172);
ad.setPhase(3);
em.persist(ad);
utx.commit();
return "saved";
}
catch (Exception ex) {
Error1=ex.getMessage();
return "error";
}