I could not find a solution in the forum for this, sorry if this is a redundant 
question. I just upgraded my existing app to use Seam 2.0 Beta, after the 
upgrade I am having problem getting the hibernate Session using 
entitymanger.getDelegate(). This is working perfectly in Seam 1.2.1.

My Components.xml
<persistence:managed-persistence-context name="entityManager" 
auto-create="true" 
persistence-unit-jndi-name="java:/myAppEntityManagerFactory"/>
  |    
  | <factory name="session" scope="STATELESS" auto-create="true" 
value="#{entityManager.delegate}"/>

@In
  | private EntityManager entityManager; //Seam Managed Persistence context, 
declared in components.xml
  | 
  | @In
  | private Session session; //factory declared in components.xml
  | 
  | DetachedCriteria dc = DetachedCriteria.forClass(getEntityBeanType());
  | for (Criterion c : criterion) {
  |     dc.add(c);
  | }
  | Criteria crit = dc.getExecutableCriteria(session);
  | return crit.list();

I am getting the follwoing exception:

16:27:35,000 ERROR [STDERR] Caused by: java.lang.ClassCastException: 
org.jboss.seam.persistence.FullTextHibernateSessionProxy
16:27:35,000 ERROR [STDERR]     at 
org.hibernate.criterion.DetachedCriteria.getExecutableCriteria(DetachedCriteria.java:52)
16:27:35,000 ERROR [STDERR]     at 
com.myapp.common.dao.IGenericDAOImpl.findByCriteria(IGenericDAOImpl.java:140)
16:27:35,000 ERROR [STDERR]     at 
com.myapp.common.dao.IGenericDAOImpl.findByCriteria(IGenericDAOImpl.java:127)
16:27:35,000 ERROR [STDERR]     at 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:27:35,000 ERROR [STDERR]     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:27:35,000 ERROR [STDERR]     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:27:35,000 ERROR [STDERR]     at 
java.lang.reflect.Method.invoke(Method.java:585)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
16:27:35,000 ERROR [STDERR]     at 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:27:35,000 ERROR [STDERR]     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:27:35,000 ERROR [STDERR]     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:27:35,000 ERROR [STDERR]     at 
java.lang.reflect.Method.invoke(Method.java:585)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
16:27:35,000 ERROR [STDERR]     at 
org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
16:27:35,000 ERROR [STDERR]     ... 186 more


As mentioned earlier, this is working without any issues in Seam 1.2.1 GA. It 
is not working in Seam 2.0 Beta. Am I missing something here, do I need to do 
any special declarations in components.xml for the session. I appreciate if 
somebody can help me on this.

BTW: I tried something like this as well, but same result.

//Session session = (Session) entityManager.getDelegate();



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085293#4085293

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085293
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to