Hibernate version:3.0
I have a deployed J2EE session bean that uses hibernate to access the database running on JBoss. This behaves normally when it is accessed by a single user, but when 2 concurrent users try to call it, I get the following HibernateException on an intermittent basis:
Quote:
org.hibernate.HibernateException: illegally attempted to associate a proxy with two open Sessions
at org.hibernate.proxy.AbstractLazyInitializer.setSession(AbstractLazyInitializer.java:68)
at org.hibernate.engine.PersistenceContext.reassociateProxy(PersistenceContext.java:485)
at org.hibernate.engine.PersistenceContext.reassociateIfUninitializedProxy(PersistenceContext.java:455)
The session bean gets an instance of the session factory in its ejbCreate method, as follows:
Code:
/**
* @ejb.create-method
* @ejb.transaction type="Required"
*/
public void ejbCreate() throws CreateException
{
// Create hibernate session factory
try
{
sessionFactory = new Configuration().configure().buildSessionFactory();
}
catch (HibernateException ex)
{
logger.error("HibernateException in method ejbCreate(). ", ex);
}
}
I then use the session factory to create a session, within all methods within the session bean. In my scenario, a single method is being called simultaniously (or thereabouts) by both client applications.
Is this a known issue, or am I doing something silly?