[jboss-user] [JBoss jBPM] - ClassCastException when trying to cast object selected from

Marvin_ do-not-reply at jboss.com
Wed May 14 12:53:24 EDT 2008


Hello,

I've got two EARs: one SEAM Project using jBPM and a second EJB Project (lets call it JBPMContextProvider) which should be able to connect to the database (Hypersonic) where all the task information of JBPM is stored.

My problem is, when I retrieve a TaskInstance-Object in JBPMContextProvider from the database, I get a ClassCastException.

The setup:
- each of the EARs has a reference of the jbpm-jpdl.jar
- the SEAM Project binds the SessionFactory to java:/projectSessionFactory
- JBPMContextProvider makes an JNDI lookup to retrieve a SessionFactory object
- to select the TaskInstances from the database, I use a named query set up in the original JBPM hibernate.cfg.xml-file and try to iterate through the result set - there the ClassCastException happens:


  | InitialContext ctx;
  | ctx = new InitialContext();
  | SessionFactory sessionFactory = (SessionFactory) ctx.lookup(JNDI);
  | sessionFactory.openSession();
  | 
  | Session session = sessionFactory.getCurrentSession();  
  | Transaction tx = session.beginTransaction(); //works fine
  | 
  | Query query2 = session.getNamedQuery("TaskMgmtSession.findTaskInstancesByActorId");
  | query2.setString("actorId", actorId);
  | result = query2.list();	
  | 			
  | for (Iterator iter = result.iterator(); iter.hasNext();) {
  |      TaskInstance ti = (TaskInstance) iter.next();              //CastException
  |       System.out.println("*** ActorId is: "+ti.getActorId()+" ***");
  | }
  | 

ErrorTrace:


  | 18:31:42,132 ERROR [STDERR] java.lang.ClassCastException: org.jbpm.taskmgmt.exe.TaskInstance
  | 18:31:42,132 ERROR [STDERR] 	at org.project.context.ContextProviderBean.getUserHistory(ContextProviderBean.java:71)
  | 18:31:42,132 ERROR [STDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 18:31:42,132 ERROR [STDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  | 18:31:42,132 ERROR [STDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  | 18:31:42,132 ERROR [STDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:81)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 18:31:42,132 ERROR [STDERR] 	at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
  | 18:31:42,132 ERROR [STDERR] 	at $Proxy63.getUserHistory(Unknown Source)
  | 



This brought me already to the idea to compare the ClassLoaders which might be a reason, but I don't know how to solve.


  | System.out.println(result.get(0).getClass().toString());
  | System.out.println(result.get(0).getClass().getClassLoader().toString());
  | System.out.println(new TaskInstance().getClass().getClassLoader().toString());
  | System.out.println(result.get(0).getClass().getClassLoader().equals(new TaskInstance().getClass().getClassLoader()));
  | 

This code delivers to STDOUT:


  | org.jboss.mx.loading.UnifiedClassLoader3 at 79b43f{ url=file:/C:/jboss-4.2.2.GA/server/default/tmp/deploy/tmp26274seam_project.ear ,addedOrder=45}
  | org.jboss.mx.loading.UnifiedClassLoader3 at 3b5587{ url=file:/C:/jboss-4.2.2.GA/server/default/tmp/deploy/tmp26273JBPMContextProviderEAR.ear ,addedOrder=44}
  | false
  | 

Thanks for any hints!

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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4150825



More information about the jboss-user mailing list