Hello,
i have a stateful session bean, which declares a dependancy on EntityManager:
Code:
@PersistenceContext(
type = PersistenceContextType.EXTENDED,
properties =
@PersistenceProperty(
name = "org.hibernate.flushmode",
value = "MANUAL"))
stateful session bean also declares a dependancy on a stateless DAO. Stateful session bean has method: createEntity:
Code:
public JobSeeker createJobSeeker(JobSeeker seeker) {
seeker = jobSeekerDAO.makePersistent(seeker);
return seeker;
}
Stateful bean as you may guess defines a dependancy on a stateless via @EJB. Stateful bean also has a @Remove method (public void submit()) - which flushes entity manager. Similar example is in Java Persistance With Hibernate on pg 727. The stateless is implemented as suggested in the example: stateless extends abstract class GenericEJB3DAO wich defines methods basic to all entities: makePersistent. Here is the caveat: stateless is a @Local bean stateful is remote, when i obtain reference to stateful, first execution of createJobSeeker, followed by submit - persists the entity (although does it in stateless bean not on submit invokation), the following invocation of the same method throws an exception:
Code:
java.lang.IllegalStateException: EntityManager is closed at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:66) at org.hibernate.ejb.AbstractEntityManagerImpl.getDelegate(AbstractEntityManagerImpl.java:559)
at www.freejobagent.com.dao.GenericEJB3DAO.getSession(GenericEJB3DAO.java:93)
at www.freejobagent.com.dao.GenericEJB3DAO.makePersistent(GenericEJB3DAO.java:59)
Now when i invoke same set of methods in about 1 - 2 minutes, its okay again. Shouldn't the container set my stateless EntityManager with the one in a stateful session bean and not keep the old closed entityManager. This is deployed on glassfish.
Thank you.