Bug 1078337 - Unfinished support for Custom Work Item Handlers in business-central
Summary: Unfinished support for Custom Work Item Handlers in business-central
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: ER1
: 6.0.2
Assignee: Maciej Swiderski
QA Contact: Radovan Synek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-19 15:50 UTC by Anton Giertli
Modified: 2018-12-04 17:48 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
It was not possible to register Custom Work Item Handlers via Business Central, even though it was possible to add them via Business Central. This has now been fixed by using reflection to register the work item beans.
Clone Of:
Environment:
Last Closed: 2014-08-06 19:50:12 UTC
Type: Enhancement
Embargoed:


Attachments (Terms of Use)
related files (46.69 KB, application/zip)
2014-03-19 16:01 UTC, Anton Giertli
no flags Details

Description Anton Giertli 2014-03-19 15:50:41 UTC
Description of problem:

Currently, it seems that the only possibility how to register custom work item handler is via

-- adding binary files with the handler code under WEB-INF/lib or WEB-INF/classes
-- register your handler in CustomWorkItemHandlers.conf

This is very uncomfortable, especially when GUI support adding custom Work Item handlers directly in the Project Editor menu.

There is possibility to configure this via kmodule.xml but it does not work.


Version-Release number of selected component (if applicable):


How reproducible:
always

Steps to Reproduce:
1. Create simple process in BC / eclipse with structure

start_node->service task->end_node 
2. register work item handler either via GUI or directly by modifying kmodule.xml in the administration menu
3. add handler jar under WEB-INF/lib
4. deploy project - it fails with Cannot instance WorkItemHandler, I am not sure what is the relationship with the https://bugzilla.redhat.com/show_bug.cgi?id=1050196
5. Let's try different approach, remove handler jar from WEB-INF/lib and add it to the artifact repository in business-central
6. add this jar as a project dependency via business-central
7. deploy project again, now it fails with
Unable to complete your request. The following exception occurred: java.lang.ClassNotFoundException:org.kie.api.runtime.process.WorkItemHandler.

I consider configuring these handlers directly in business-central.war as a workaround and not a solution, given the fact
--BC gui supports adding project dependencies
--BC gui supports adding WorkItemHandlers
--kmodule.xml xsd supports workitemhandlers element
--BC should support kmodule.xml completely

Actual results:

Deployment of project which is configured via business-central to use workitemhandlers fails.

Expected results:
Deployment of this kind of project is succesfull.

Additional info:

Comment 2 Anton Giertli 2014-03-19 16:01:42 UTC
Created attachment 876403 [details]
related files

Comment 3 Radovan Synek 2014-03-21 08:41:14 UTC
Raising severity as (correct me if I am wrong) there is no way how to get new work item into business-central runtime (kdeployment) without restarting the server - to put the JAR with work item handler on classpath and register it as Anton described.

Given a fact that the handler can be registered in GUI (Project Editor -> Knowledge bases and sessions) and is possible to upload JAR with implementation and use it as a dependency of project, is this issue really enhancement?

Comment 5 Maciej Swiderski 2014-03-21 11:46:01 UTC
Actually it does work but the work item handler must be be given as MVEL expression for instance: new org.jbpm.wih.CustomHandler()

and that should work for both handlers as maven dependency and when placed in web-inf/lib. Alternatively you can also use CDI based producers, see docs here: http://docs.jboss.org/jbpm/v6.0.1/userguide/jBPMCoreEngine.html#d0e2140 look at section 5.4.4.2.1. Registering handlers and listeners in CDI environment

I'll fix the resolution so simple FQCN would work as well.

Comment 6 Maciej Swiderski 2014-03-21 12:36:28 UTC
fixed by falling back to reflection based bean created in case MVEL or CDI based ones fail

drools
master:
https://github.com/droolsjbpm/drools/commit/e9611073ea22b68db0ea2e2c28b3e183abdfb71d

6.0.x:
https://github.com/droolsjbpm/drools/commit/31cee34c710ba95af442440aa05bbcdbcb18750f

Comment 7 Anton Giertli 2014-03-21 13:45:21 UTC
Hi Maciej,

I have tried two tests, with this kmodule.xml (altered and copied from business-central) :
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <kbase name="defaultKieBase" default="true" eventProcessingMode="cloud" equalsBehavior="identity" declarativeAgenda="disabled" scope="javax.enterprise.context.ApplicationScoped" packages="*">
    <ksession name="defaultKieSession" type="stateful" default="true" clockType="realtime" scope="javax.enterprise.context.ApplicationScoped">
      <workItemHandlers>
        <workItemHandler type="new com.ihealth.sample.helloworld.workitem.SystemOutWorkItemHandler()" name="Service Task"/>
      </workItemHandlers>
    </ksession>
  </kbase>
</kmodule>

Test 1) Add jar with handler as a dependency. Project build failed with:

Unable to complete your request. The following exception occurred: java.lang.ClassNotFoundException:org.kie.api.runtime.process.WorkItemHandler.

So do I really need to add kie-api library explicitely ?

Test 2) Add jar with handler in WEB-INF/lib. Project built/deployed/executed successfully.


Is this expected behavior,

Thanks,
Anton

Comment 8 Maciej Swiderski 2014-03-21 13:57:49 UTC
Anton,

that is correct, you need to define dependency to kie-api as handler implements interface from it. Usually handlers are packaged as separate jar and then attached to kjar project. So to be able to build the jar with handler you need to have dependency to kie-api in you maven project. So there is no difference from building it outside of kie-wb and inside it.

Comment 9 Anton Giertli 2014-03-21 14:03:50 UTC
Hi,

I have clarified this with Maciej, and once I have removed
<scope>provided</scope> for kie-api dependency from my handler project this works as expected.

By expected I mean I have hit this bug
https://bugzilla.redhat.com/show_bug.cgi?id=1050196

Once this and above bugzilla are fixed, both ways should work.

Anton.

Comment 10 Marek Baluch 2014-03-21 14:24:10 UTC
(In reply to Anton Giertli from comment #9)
> By expected I mean I have hit this bug
> https://bugzilla.redhat.com/show_bug.cgi?id=1050196
> 
> Once this and above bugzilla are fixed, both ways should work.

Anton the BZ should already be fixed!

Comment 11 Anton Giertli 2014-03-21 14:49:45 UTC
Hi Marek,

I should have mentioned it explicitly, but 99% of the time I use only those releases which are available to the customers (it's really natural thing for most of the GSS engineers). Now, it is BPM 6.0.0 GA. Looking at that other bugzilla I see it is fixed in the BPMS 6.0.1.ER2, but I haven't tried this version, only GA. I am sorry for the confusion.

Cheers,
Anton

Comment 12 Radovan Synek 2014-05-22 14:02:48 UTC
Verified with BPMS-6.0.2.ER2


Note You need to log in before you can comment on or make changes to this bug.