classcastexception « Glassfish « JPA Q&A

1. Strange classCastException hibernate 3.5 glassfish

Hi I have a problem that I can't solve on my own. I have a war file packaged in ear and running on glassfish 3.0.1 with hibernate 3.5 as JPA provider. ...

2. SOLUTION TO:ClassCastException redeploying WebServices with JPA

SOLUTION: close the entity manager factory after usage. It is not pretty and loads the garbage collection, but it work!!!! public List getContextList(){ EntityManager em = emf.getEntityManager(); try { javax.persistence.Query q = em.createQuery("select r from Context as r"); return q.getResultList(); } catch (NoResultException noResultException) { return null; } finally { cleanup(); } } public synchronized void cleanup() { if (emf != ...

3. ClassCastException when using JPA result

I loading a JPA entity from my POJO DAO that uses @PersistenceContext and @Transactional from Spring 2.5. The result that is returned has the same name (ex: but I get a class cast exception when I try to cast from Object to the entity bean class so that I can use it. I wrote more details here: