-
1. Re: jBPM 6.2 : Sample code to invoke a java method from service task
abhijithumbe Jul 15, 2015 7:23 AM (in response to qwirkle101)Build standard jar of workItemHandler class using jar -cvf command and add jar with handler class under jbpm-console.war/WEB-INF/lib or classes directory.
OR
Upload jar with handler class into business-central via Authoring -> Artifact Repository.
Add this artifact as a project dependency via `Authoring -> Project Authoring -> Tools -> Project Editor -> Project Settings -> Dependencies -> Add from Repository.
Register WorkItem handler in kmodule.xml of your project(kajr), like this:
~~~
<workItemHandlers>
<workItemHandler name="Sysout" type="new com.sample.helloworld.workitem.SystemOutWorkItemHandler()"/>
</workItemHandlers>
~~~
In jBPM 6.2 we can register workItemHandler through jbpm-console.war/WEB-INF/classes/META-INF/kie-wb-deployment-descriptor.xml as well.
Hope it helps
-
2. Re: jBPM 6.2 : Sample code to invoke a java method from service task
qwirkle101 Jul 19, 2015 1:40 AM (in response to abhijithumbe)Thanks Abhijit. I followed the below steps
1. Created jar with an WIH
public class HelloWorkItemHandler implements WorkItemHandler {
public void abortWorkItem(WorkItem wi, WorkItemManager wim) {
System.out.println("Oh no, my item aborted..");
}
public void executeWorkItem(WorkItem wi, WorkItemManager wim) {
System.out.println("Hello World!");
}
}
2. Imported it to the repository
3. Add it to the project (HR) as a project dependency. PS: I added a new process to the jpm-playground - HR
Service Task Entry
- Service Interface: mytest.jbpm.HelloWorkItemHandler
- Service Operation: executeWorkItem
4. Registered workItemHandler through jbpm-console.war/WEB-INF/classes/META-INF/kie-wb-deployment-descriptor.xml
I'm getting the error when I run the instance : "java.lang.NoSuchMethodException: mytest.jbpm.HelloWorkItemHandler.executeWorkItem(java.lang.Object)"
Alos, I see the following exception in the log:
- "2015-07-18 22:17:16,487 WARN [org.jbpm.kie.services.impl.KModuleDeploymentService] (MSC service thread 1-8) Unexpected error while deploying unit org.guvnor:guvnor-asset-mgmt-project:6.2.0.Final: java.lang.RuntimeException: [Error: could not resolve class: mytest.jbpm.HelloWorkItemHandler from [Module "deployment.jbpm-console.war:main" from Service Module Loader]]
[Near : {... new mytest.jbpm.HelloWorkItemHandl ....}]"
Am I missing anything?
-
3. Re: jBPM 6.2 : Sample code to invoke a java method from service task
abhijithumbe Jul 20, 2015 9:57 AM (in response to qwirkle101)Hi,
java.lang.NoSuchMethodException: Looks like you are using different version of JDK at compile time and at runtime. Make sure you are using same version of JDK.
I have attached WorkItemHandler jar and kjar for your reference, take a look at it.
-
project1-1.1.01.jar 6.6 KB
-
TestWorkItemHandler.jar 2.5 KB
-