6 Replies Latest reply on Jun 24, 2010 2:41 PM by jordi elies

    ClassCastException: JpdlProcessDefinition cannot be cast to ProcessDefinitionImpl

    jordi elies Newbie

      Hello everybody,

       

      I have a curious problem when I try to get all ProcessDefinitions of the RepositoryService. I execute this few lines:

       

       

      {code:java}

      ...

      RepositoryService repositoryService = processEngine.getRepositoryService();

      ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();

      List<ProcessDefinition> p = pdq.list();

      ...

      {code}

       

      The first time I start jboss server all works fine, all process definitions are obtained without problem. The problem comes when I redeploy the webapp. Once redeployed, I try to get all the process definitions and a class cast exception is thrown on:

      {code:java} List<ProcessDefinition> p = pdq.list(); {code}

       

      The stacktrace:

       

      {code:java}

      13:41:12,260 INFO  [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl@14d9f8e

      java.lang.ClassCastException: org.jbpm.jpdl.internal.model.JpdlProcessDefinition cannot be cast to org.jbpm.pvm.internal.model.ProcessDefinitionImpl

      at org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.execute(ProcessDefinitionQueryImpl.java:72)

      at org.jbpm.pvm.internal.query.AbstractQuery.execute(AbstractQuery.java:87)

      at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)

      at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45)

      at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)

      at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:55)

      at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)

      at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)

      at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)

      at org.jbpm.pvm.internal.query.AbstractQuery.untypedList(AbstractQuery.java:68)

      at org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.list(ProcessDefinitionQueryImpl.java:141)

      ****at com.workflow.WorkflowController.showForm(WorkflowController.java:32) [here is where list() method is called]

      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:597)

      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)

      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)

      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)

      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)

      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)

      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)

      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)

      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

      at java.lang.Thread.run(Thread.java:619)

      13:41:12,291 ERROR [[spring]] Servlet.service() para servlet spring lanzó excepción

      java.lang.ClassCastException: org.jbpm.jpdl.internal.model.JpdlProcessDefinition cannot be cast to org.jbpm.pvm.internal.model.ProcessDefinitionImpl

      at org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.execute(ProcessDefinitionQueryImpl.java:72)

      at org.jbpm.pvm.internal.query.AbstractQuery.execute(AbstractQuery.java:87)

      at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)

      at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45)

      at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)

      at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:55)

      at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)

      at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)

      at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)

      at org.jbpm.pvm.internal.query.AbstractQuery.untypedList(AbstractQuery.java:68)

      at org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.list(ProcessDefinitionQueryImpl.java:141)

      at sicar.snc.workflow.WorkflowController.showForm(WorkflowController.java:32)

      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:597)

      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)

      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)

      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)

      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)

      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)

      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)

      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)

      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

      at java.lang.Thread.run(Thread.java:619)

      {code}

       

       

       

       

       

       

      Inside jBpm code, the line with **** is where ClassCastException is thrown:

      {code:java}

      public class ProcessDefinitionQueryImpl extends AbstractQuery implements ProcessDefinitionQuery {

      ...

       

        public Object execute(Session session) {

          List<Map<String, Object>> propertyMaps = (List<Map<String, Object>>) super.execute(session);

       

          List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>();

          for (Map<String, Object> properties: propertyMaps) {

            String deploymentId = properties.get("deploymentDbid").toString();

            String objectName = (String)properties.get("objectName");

            RepositorySession repositorySession = EnvironmentImpl.getFromCurrent(RepositorySession.class);

            ****ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) repositorySession.getObject(deploymentId, objectName);

            processDefinitions.add(processDefinition);

          }

       

          return processDefinitions;

        }

       

      ...

      }

      {code}

       

       

       

      I'm doing something wrong? When I look for the process deployments with a DeploymentQuery there isn't any problem.

       

      Thanks in advance, any help would be appreciated.

       

      PS: I'm working with jbpm 4.3, spring, jboss.5.1.0.GA and I've the jBpm engine running embedded in the same web application.

        • 1. Re: ClassCastException: JpdlProcessDefinition cannot be cast to ProcessDefinitionImpl
          HuiSheng Xu Master

          Hi Jordi,

            It seems there are multiple jbpm.jar or jbpm-jpdl.jar in your classpath.  The same class JpdlProcessDefinition were loaded by difference ClassLoader.

          • 2. Re: ClassCastException: JpdlProcessDefinition cannot be cast to ProcessDefinitionImpl
            jordi elies Newbie

            Hi Huisheng Xu,

             

            I have been looking for these multiple jar files and I can't find them. My jars on WEB-INF/lib are:

             

             

            jars generated by ant with jbmp 4.3 build file (ant -Dtx=spring create.user.webapp):
            activation.jar
            antlr-runtime.jar
            antlr.jar
            commons-collections.jar
            dom4j.jar
            drools-api.jar
            drools-compiler.jar
            drools-core.jar
            freemarker.jar
            hibernate-cglib-repack.jar
            hibernate-core.jar
            hsqldb.jar
            janino.jar
            javassist.jar
            jbpm.jar
            joda-time.jar
            livetribe-jsr223.jar
            mail.jar
            mvel2.jar
            slf4j-api.jar
            slf4j-jdk14.jar
            [I've deleted the juel (juel, juel-engine, juel-impl) jars.]
            [I think I should clean some jars from here, because I supose drools, antlr, etc. aren't used.]

            spring stuff:
            org.springframework.aop-3.0.1.RELEASE-A.jar
            org.springframework.asm-3.0.1.RELEASE-A.jar
            org.springframework.beans-3.0.1.RELEASE-A.jar
            org.springframework.context-3.0.1.RELEASE-A.jar
            org.springframework.context.support-3.0.1.RELEASE-A.jar
            org.springframework.core-3.0.1.RELEASE-A.jar
            org.springframework.expression-3.0.1.RELEASE-A.jar
            org.springframework.jdbc-3.0.1.RELEASE-A.jar
            org.springframework.jms-3.0.1.RELEASE-A.jar
            org.springframework.orm-3.0.1.RELEASE-A.jar
            org.springframework.test-3.0.1.RELEASE-A.jar
            org.springframework.transaction-3.0.1.RELEASE-A.jar
            org.springframework.web-3.0.1.RELEASE-A.jar
            org.springframework.web.servlet-3.0.1.RELEASE-A.jar
            spring.tld
            spring-form.tld

            spring3 bean validation:
            validation-api-1.0.0.GA.jar
            hibernate-validator-4.0.2.GA.jar

             

             

             

            Jboss /lib and /common/lib doesn't contain any jbpm-related jar...

             

            Any other suggestion ? Thanks a lot for the reply Huisheng!

            • 3. Re: ClassCastException: JpdlProcessDefinition cannot be cast to ProcessDefinitionImpl
              jordi elies Newbie

              Hello again,

               

              I was looking this morning for some workaround... I can't solve it yet. When the application is loaded for second time on the application server, the class cast exception appears when list() method is called. It happens in Tomcat (version 6.0.26) too.
              Debugging the code, i've evaluated the expression (see first message for code details):

              {code:java} repositorySession.getObject(deploymentId, objectName) instanceof ProcessDefinitionImpl {code}

              Obviously, with the first application deploy, the result is true, consequently the cast succeeds. With the second deploy the expression results false, then the cast throw the mentioned exception.
              I'll still looking for any solution... I hate this kind of rare errors which always have a simple solution!
              • 4. Re: ClassCastException: JpdlProcessDefinition cannot be cast to ProcessDefinitionImpl
                Nenad Popovic Newbie

                Hi jordi,

                 

                How do you bind/unbind your ProcessEngine to JNDI? If you don't unbind it from JNDI, that can be reason for ClassCastExceptions on hot deploy. Also check other posts regarding ClassCastException on this forum.

                • 5. Re: ClassCastException: JpdlProcessDefinition cannot be cast to ProcessDefinitionImpl
                  jordi elies Newbie

                  Thanks for your reply Nenad,

                   

                  I don't bind the ProcessEngine to JNDI because my ProcessEngine is running inside my application. I don't need to use it as a service, only this application will use this ProcessEngine. I've installed the jBPM as a webapp (following the jBPM doc: http://docs.jboss.com/jbpm/v4/userguide/html_single/#userwebapp).
                  Anyway, your suggestion is pretty good, probably some class stills in JBoss memory or similar and when I redeploy the application and use the process engine the ClassCastException is thrown.
                  I'll continue searching more fore ClassCastException on this forum, I've found similar problems but not exactly the same.
                  • 6. Re: ClassCastException: JpdlProcessDefinition cannot be cast to ProcessDefinitionImpl
                    jordi elies Newbie

                    Finally solved with the 4.4 snapshot that posted HuiSheng Xu here. Thanks a lot, I'll wait for the official release!