Hi,
I have a ClassCastException on call to getDelegate method of EntityManager class. My code is as following :
Code:
protected javax.persistence.EntityManager emanager;
protected org.hibernate.ejb.HibernateEntityManager hibernateSession;
@javax.persistence.PersistenceContext(unitName = "t4Seam")
public void setEntityManager(javax.persistence.EntityManager entityManager) {
this.emanager = entityManager;
this.hibernateSession = (org.hibernate.ejb.HibernateEntityManager) entityManager.getDelegate();
}
And the stack trace :
Code:
Caused by: java.lang.ClassCastException: org.hibernate.impl.SessionImpl
at t4.core.user.internal.UserAccountDaoBase.setEntityManager(UserAccountDaoBase.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.injection.JndiMethodInjector.inject(JndiMethodInjector.java:94)
at org.jboss.injection.JndiMethodInjector.inject(JndiMethodInjector.java:84)
at org.jboss.injection.JndiMethodInjector.inject(JndiMethodInjector.java:58)
at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:111)
at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:49)
at org.jboss.ejb3.ThreadlocalPool.create(ThreadlocalPool.java:50)
at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:90)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
at $Proxy306.findByUsername(Unknown Source)
at t4.core.user.internal.UserInternalServiceBean.handleLoadUserAccount(UserInternalServiceBean.java:48)
at t4.core.user.internal.UserInternalServiceBase.loadUserAccount(UserInternalServiceBase.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
What is strange is that this piece of code is OK on unit tests running with OpenEJB. The problem occurs when running on JBoss AS only.
I thought it could come from conflicts between Hibernate jars bundled in JBoss AS and the ones in my EAR (hibernate-3.2.0.GA, hibernate-annotations-3.2.0.GA and hibernate-entitymanager-3.2.0.GA), but removing them from lib JBoss directory changed nothing.
Anyone encoutered a similar problem ?
Olivier