9 Replies Latest reply on Sep 22, 2014 11:30 PM by Steven Hu

    passing and retrieving custom object in jBPM6

    Jaykumar Pandya Novice

      Have created one entity class (with Serialize attributes) and corresponding JAR file also uploaded in jBPM6 process. I have create one process where i want to use an object of this entity class and so i have defined an object of this class as a process variable. When i am strting this process from JAVA using REST API as i am passing Map as a parameters to start process i am getting an exception. I also have defined the same object variable in jBPM also. Can anybody please help me to understand how i can pass my entity class object in jBPM and access the same?


      code is

      TaskRequest taskObj = new TaskRequest();



        Map<String, Object> mapObj = new HashMap<String, Object>();

        mapObj.put("extobj", taskObj);

        ProcessInstance pi=  process.startProcess("jbpmtesting.ExternalTest", mapObj);


      and exception is


      ava.lang.RuntimeException: WorkflowRuntimeException thrown with message '[jbpmtesting.ExternalTest:50 - externalT:2] -- org.apache.xerces.dom.ElementNSImpl cannot be cast to com.cred.entity.TaskRequest' Caused by: ClassCastException thrown with message 'org.apache.xerces.dom.ElementNSImpl cannot be cast to com.cred.entity.TaskRequest '

        • 1. Re: passing and retrieving custom object in jBPM6
          Stylianos Koussouris Newbie

          Is it in the classpath of the process? I assume a dependency on the deployed jar containing the entity has been configured from the project?

          • 2. Re: passing and retrieving custom object in jBPM6
            Jaykumar Pandya Novice

            Yes JAR file for this entity class is there in class path and also have added the same as a dependencies in jBPM project

            • 3. Re: passing and retrieving custom object in jBPM6
              Maciej Swiderski Master

              the problem is current limitation - only kjar dependencies are scanned for classes, so add to your jar where you have the custom types META-INF/kmodule.xml and that should be recognized and registered as known class in JAXBContext on REST api server side.


              This is sort of JAXBContext limitation as it must know all the classes in advance so classpath scanning would be required but it's inefficient and very time consuming especially for large classpath tree. So we are looking at the possible solutions for it and hopefully will add it for next version.



              please note that you might need to use 6.1 beta version for this feature.



              • 4. Re: passing and retrieving custom object in jBPM6
                Jaykumar Pandya Novice

                can you pls guide how to update my jar in jBPM using kmodule?

                • 5. Re: passing and retrieving custom object in jBPM6
                  Hitesh Pandya Newbie

                  Hi, Did you find a solution for this issue? I am facing the same issue using EAP 6.1 with jBPM.

                  • 6. Re: passing and retrieving custom object in jBPM6
                    Grady Cooper Newbie

                    Maciej answer above worked for me; however, I'll give an example to help illustrate the solution.


                    I was able to get this to work on 6.1.0.Final by simply adding a kmodule.xml to the jar file that contained my data class.


                    I have two projects, project1 contains my business processes and project2 contains my data model classes.


                    project1 (contains my bpmn's)


                         src/main/resources/test.bpmn <---- References TaskRequest.java in project2 below


                    project2 (contains my model)


                         src/main/resources/META-INF/kmodule.xml  <----- ADDED THIS TO MAKE project2.jar a KJAR so the TaskRequest.class would be found by jBPM



                    contents of project2's kmodule.xml


                    <!-- empty kmodule to cause jBPM to scan this jar for data types:  https://developer.jboss.org/thread/239542 -->

                    <kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule"/>

                    • 7. Re: passing and retrieving custom object in jBPM6
                      Steven Hu Newbie

                      Hi, can you give some detailed suggestion on how to upload the business project contained custom object? Thank you very much.


                      Right now, I have two projects exactly same with yours in your illustration. Also I add a kmodule file(same with yours) into my java project and jbpm project respectively. And then I export them as jar respectively. Next, I upload them both into jbpm 6.1.0.Final wb. And create deployment unit for each. But I received an error:


                      2014-09-19 17:26:17,071 ERROR [org.drools.compiler.kie.builder.impl.AbstractKieModule] (default task-10) Unable to build KieBaseModel:kbase

                      Error importing : 'com.sample.MyVo'

                      Unable to build expression for action 'System.out.println("Hello,"+person.name);' :java.lang.ClassNotFoundException: Unable to find class 'com.sample.MyVo' : Process com.sample.bpmn.Sample Process(com.sample.bpmn.hello)


                      2014-09-19 17:26:17,237 WARN  [org.jbpm.kie.services.impl.KModuleDeploymentService] (default task-10) Unexpected error while deploying unit com.sample:MySample:1.0: java.lang.IllegalStateException: Cannot find kbase, either it does not exist or there are multiple default kbases in kmodule.xml

                        at org.jbpm.kie.services.impl.KModuleDeploymentService.deploy(KModuleDeploymentService.java:106) [jbpm-kie-services-6.1.0.Final.jar:6.1.0.Final]

                        at org.jbpm.kie.services.impl.KModuleDeploymentService$Proxy$_$$_WeldClientProxy.deploy(Unknown Source) [jbpm-kie-services-6.1.0.Final.jar:6.1.0.Final]

                        at org.jbpm.console.ng.bd.backend.server.DeploymentManagerEntryPointImpl.deploy(DeploymentManagerEntryPointImpl.java:113) [jbpm-console-ng-business-domain-backend-6.1.0.Final.jar:6.1.0.Final]

                        at org.jbpm.console.ng.bd.backend.server.DeploymentManagerEntryPointImpl.deploy(DeploymentManagerEntryPointImpl.java:103) [jbpm-console-ng-business-domain-backend-6.1.0.Final.jar:6.1.0.Final]


                      • 8. Re: passing and retrieving custom object in jBPM6
                        Grady Cooper Newbie

                        My jars were packaged via maven and deploy via workbench (not built).  Use maven to package workbench to deploy and it should work.

                        • 9. Re: passing and retrieving custom object in jBPM6
                          Steven Hu Newbie

                          thanks for your reply. It is really helpful. I converted my java project into maven project. it worked now.