JBPM Case with Business Rule task

699 views
Skip to first unread message

Gagan Tewari

unread,
Mar 23, 2018, 10:40:51 AM3/23/18
to jBPM Usage
Hi,

I am following http://mswiderski.blogspot.in/2017/04/control-business-rules-execution-from.html to create a case that will be using a rule to set some data on caseFile. 

In the workbench, i have two projects:

Project A: It has case definition, with Business Rule Task with RuleFlowGroup set as per rule definition. The deployment descriptor for this has a new Work item Handler added as 

new org.jbpm.process.workitem.bpmn2.BusinessRuleTaskHandler("groupId","artifcatid","version");

Project B: It only has the drl file that defines the rule. The rule is simple with no condition, and it just as sysout to make sure that the rule has triggered.

Both Project A and B are build and deployed.

When case is created, it gets completed however, I don't see the sysout from rule that should have been triggered.

As per the article, I have also tried using Work item handler as:

new org.kie.server.client.integration.RemoteBusinessRuleTaskHandler("http://localhost:8080/kie-server/services/rest/server","krisv","krisv",classLoader);

However, the result it still same, and case gets completed, however the rule is not triggered.

My rule definition is:

//from row number: 1
rule "1 DerivePriority"
    no-loop true
ruleflow-group 'priorityRuleGroup'
dialect "mvel"
when
    
then
    
System.out.println("Applied Rule, new priority 1");
end

I have attached the bpmn2 file and deployment descriptor. I am using JBPM release 7.6.0.Final.

I would appreciate any help to understand what I am dong wrong? Btw, when I use the same rule file as part of same project (project A), then it works as expected, and rule is triggered and I can sysout statement in log.

Thanks!
Gagan
com.gagan.case_poc.casePoc.v1.0.bpmn2
deployment-descriptor.xml

Maciej Swiderski

unread,
Mar 23, 2018, 2:44:09 PM3/23/18
to Gagan Tewari, jBPM Usage
you’re using wrong task type - businessRuleTask (Which is standard BPMN2 task) will only work with rules in the same project (kjar). If you want to use another project for rules then you need to use custom task like this https://github.com/mswiderski/decision-examples/blob/master/decision-process/src/main/resources/myteam/person-process.bpmn2#L24

in this repo (which is actually linked at the end of blog) you will fine all the pieces needed to get this to work.

Maciej

--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-usage/bfd2f79b-0776-445f-b9fc-b8b3aa03f5e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<com.gagan.case_poc.casePoc.v1.0.bpmn2><deployment-descriptor.xml>

Gagan Tewari

unread,
Mar 26, 2018, 2:07:30 AM3/26/18
to Maciej Swiderski, jBPM Usage
Hi Maciej,

I am using 7.6.0.Final release of JBPM, and here I don't see any option of picking a "Custom Task". I see following tasktype listed in workbench under "Task" Category:

User, Send, Receive,Manual,Service,Manual,Business Rule, Script, None

I tried using "None", but then it fails to validate with error that TaskType is not defined. However, If I use any task type, then it gets converted to one of the above type. 

Error that I am seeing when using "None" without specifying "TaskType" is:

2018-03-26 11:03:45,149 INFO  [org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller] (default task-29) Sorting diagram elements using DIZorderComparator
2018-03-26 11:03:45,467 ERROR [org.jbpm.designer.server.indexing.BPMN2FileIndexer] (Thread-249) Error: Process 'casePoc' [case-poc.casePoc]: Node 'Business Rule Task ' [4] Task has no task type.
2018-03-26 11:03:45,816 ERROR [org.jbpm.designer.server.indexing.BPMN2FileIndexer] (Thread-249) Trying to finish indexing process 'case-poc.casePoc/casePoc' despite 1 validation errors.
2018-03-26 11:08:20,437 ERROR [org.drools.compiler.kie.builder.impl.KieProject] (default task-8) Unable to build KieBaseModel:defaultKieBase
[-1,-1]: Process 'casePoc' [case-poc.casePoc]: Node 'Business Rule Task ' [4] Task has no task type.

Am I missing something?

Thanks!
Gagan


Maciej

To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+unsubscribe@googlegroups.com.

Maciej Swiderski

unread,
Mar 26, 2018, 2:54:14 AM3/26/18
to Gagan Tewari, jBPM Usage
All custom tasks are in Service Task category by default. When it comes to rules related tasks described in that article they are in Decision task category. If you create new project in 7.6 then you should find them in the pallete.

Maciej

Gagan Tewari

unread,
Mar 26, 2018, 3:17:59 AM3/26/18
to Maciej Swiderski, jBPM Usage
Thanks Maciej.

I am new to JBPM, so things are making more sense slowly. 

After reading about it more, i think to define a custom task , first i will have to create a new Work definition, like you have as below:


[
"name" : "BusinessRuleTask",
"parameters" : [
"Language" : new StringDataType(),
"KieSessionName" : new StringDataType(),
"KieSessionType" : new StringDataType()
],
"displayName" : "Business Rule Task",
"icon" : "defaultlogicon.gif",
"category" : "Decision tasks"
]

And then in the deployment descriptor associate RemoteBusinessRuleTaskHandler with this custom task.

One query though, I see that RemoteBusinessRuleTaskHandler internally uses "ContainerId" parameter to execute command in Rule engine, but I don't see this being defined in above Workdefinition. Is this a miss or it is defined somewhere else?

Thanks!
Gagan


Maciej Swiderski

unread,
Mar 26, 2018, 3:23:33 AM3/26/18
to Gagan Tewari, jBPM Usage
there is no default WID entry for RemoteBusinessTaskHandler so you would have to create new one and add the parameters it expects so at design time you would be able to use them.

Maciej

Gagan Tewari

unread,
Mar 26, 2018, 6:53:42 AM3/26/18
to Maciej Swiderski, jBPM Usage
Hi Maciej,

Thanks a lot for your inputs. I managed to create custom task that is now using the RemoteBusinesTaskHandler to send request to remote rule-engine. However, for some reasons it is failing with error "com.thoughtworks.xstream.security.ForbiddenClassException"

Detailed error log:

Caused by: com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.security.ForbiddenClassException
cause-message       : com.gagan.poc_data_model.OptimaCase
class               : org.drools.core.runtime.impl.ExecutionResultImpl
required-type       : org.drools.core.runtime.impl.ExecutionResultImpl
converter-type      : org.drools.core.runtime.help.impl.XStreamXML$BatchExecutionResultConverter
path                : /response/result/result/com.gagan.poc_data_model.OptimaCase
line number         : 4
class[1]            : org.kie.server.api.model.ServiceResponse
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
version             : 7.5.0.Final
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1486)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1466)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1337)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1328)
at org.kie.server.api.marshalling.xstream.XStreamMarshaller.unmarshall(XStreamMarshaller.java:217)
at org.kie.server.client.impl.AbstractKieServicesClientImpl.deserialize(AbstractKieServicesClientImpl.java:590)
at org.kie.server.client.impl.AbstractKieServicesClientImpl.makeHttpPostRequestAndCreateServiceResponse(AbstractKieServicesClientImpl.java:286)
at org.kie.server.client.impl.AbstractKieServicesClientImpl.makeHttpPostRequestAndCreateServiceResponse(AbstractKieServicesClientImpl.java:264)
at org.kie.server.client.impl.RuleServicesClientImpl.executeCommandsWithResults(RuleServicesClientImpl.java:66)
at org.kie.server.client.integration.RemoteBusinessRuleTaskHandler.executeWorkItem(RemoteBusinessRuleTaskHandler.java:125)
at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalExecuteWorkItem(JPAWorkItemManager.java:69)
at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:140)
... 135 more
Caused by: com.thoughtworks.xstream.security.ForbiddenClassException: com.gagan.poc_data_model.OptimaCase
at com.thoughtworks.xstream.security.NoTypePermission.allows(NoTypePermission.java:26)
at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:74)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at org.kie.server.api.marshalling.xstream.XStreamMarshaller$1.realClass(XStreamMarshaller.java:127)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47)
at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:72)
at org.drools.core.runtime.help.impl.XStreamXML$BatchExecutionResultConverter.unmarshal(XStreamXML.java:980)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 158 more


Any suggestion? the fact class  "com.gagan.poc_data_model.OptimaCase" is part of a different project that is added as dependency to both project containing the process definition and the project that has the rule file.

Thanks!
Gagan

Gagan Tewari

unread,
Mar 26, 2018, 9:19:09 AM3/26/18
to Maciej Swiderski, jBPM Usage
I think the "_" in my data model class package name ( com.gagan.poc_data_model.OptimaCase) is causing the problem. I will try after giving it a more conventional name without any "_".

Thanks!
Gagan

Gagan Tewari

unread,
Mar 26, 2018, 10:03:37 AM3/26/18
to Maciej Swiderski, jBPM Usage
I tried again after changing the package to a simple one, but still getting the same error. 

In the logs I could see that rule engine was executed and response was send back:

2018-03-26 19:10:43,002 DEBUG [org.kie.server.client.integration.RemoteBusinessRuleTaskHandler] (default task-47) Facts to be inserted into working memory {caseInput=com.gagan.casedatamodel.CaseData@378eabc}
2018-03-26 19:10:43,007 DEBUG [org.kie.server.client.impl.AbstractKieServicesClientImpl] (default task-47) About to send POST request to 'http://localhost:8080/kie-server/services/rest/server/containers/instances/caseBusinessRules' with payload '<batch-execution>
  <insert out-identifier="92_caseInput" return-object="true" entry-point="DEFAULT">
    <com.gagan.casedatamodel.CaseData>
      <caseType>Billing</caseType>
      <caseSubType>Payments</caseSubType>
    </com.gagan.casedatamodel.CaseData>
  </insert>
  <fire-all-rules out-identifier="Fired"/>
</batch-execution>'
2018-03-26 19:10:43,063 DEBUG [org.kie.server.client.impl.AbstractKieServicesClientImpl] (default task-47) About to deserialize content: 
 '<response type="SUCCESS" msg="Container caseBusinessRules successfully called.">
  <result class="execution-results">
    <result identifier="92_caseInput">
      <com.gagan.casedatamodel.CaseData>
        <caseType>Billing</caseType>
        <caseSubType>Payments</caseSubType>
      </com.gagan.casedatamodel.CaseData>
    </result>
    <result identifier="Fired">
      <int>0</int>
    </result>
    <fact-handle identifier="92_caseInput" external-form="0:1:1162679108:1162679108:1:DEFAULT:NON_TRAIT:com.gagan.casedatamodel.CaseData"/>
  </result>
</response>' 
 into type: 'class org.kie.server.api.model.ServiceResponse'

However, while handling the response, it fails with error:

---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.security.ForbiddenClassException
cause-message       : com.gagan.casedatamodel.CaseData
class               : org.drools.core.runtime.impl.ExecutionResultImpl
required-type       : org.drools.core.runtime.impl.ExecutionResultImpl
converter-type      : org.drools.core.runtime.help.impl.XStreamXML$BatchExecutionResultConverter
path                : /response/result/result/com.gagan.casedatamodel.CaseData
line number         : 4
class[1]            : org.kie.server.api.model.ServiceResponse
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
version             : 7.5.0.Final

Stack trace:

Caused by: com.thoughtworks.xstream.security.ForbiddenClassException: com.gagan.casedatamodel.CaseData
at com.thoughtworks.xstream.security.NoTypePermission.allows(NoTypePermission.java:26)
at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:74)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at org.kie.server.api.marshalling.xstream.XStreamMarshaller$1.realClass(XStreamMarshaller.java:127)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47)
at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:72)
at org.drools.core.runtime.help.impl.XStreamXML$BatchExecutionResultConverter.unmarshal(XStreamXML.java:980)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)

I will appreciate any input here as I seems to have hit a major roadblock now without much clue about the possible reason of the issue.

Thanks in advance.

Gagan

Maciej Swiderski

unread,
Mar 27, 2018, 3:01:00 AM3/27/18
to Gagan Tewari, jBPM Usage
In general all classes loaded by kjar class loader should be allowed but you can explicitly mark classes/packages with system property:

-Dorg.kie.server.xstream.enabled.packages=com.gagan.**

Maciej
>>>> To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.

Gagan Tewari

unread,
Mar 28, 2018, 1:30:03 AM3/28/18
to Maciej Swiderski, jBPM Usage
Hi Maciej,

Thanks a lot for your help. After setting this property, it worked like a charm!!

Thanks again!

Gagan

>>>> To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+unsubscribe@googlegroups.com.

sudha...@gmail.com

unread,
Feb 28, 2019, 12:35:44 AM2/28/19
to jBPM Usage
Maciej/Gagan,

I'm unable to open a form from task inbox and getting the ForbiddenClass exception (screenshot attached with this post). 

Please let me know where to set the property '-Dorg.kie.server.xstream.enabled.packages'. 

Thanks
>>>> To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
error.jpg

Maciej Swiderski

unread,
Feb 28, 2019, 5:00:21 AM2/28/19
to sudha...@gmail.com, jBPM Usage
This needs to be set on server startup for instance ./standalone.sh -Dorg.kie.server.xstream…..

Maciej


For more options, visit https://groups.google.com/d/optout.
<error.jpg>

sudha...@gmail.com

unread,
Feb 28, 2019, 11:52:41 PM2/28/19
to jBPM Usage
Maciej,

Thanks a lot for your inputs. ForbiddenClassException is resolved.

However, i'm facing a warning in the parent process for all human tasks, as 'Warning:This form has been automatically generated. This usually means that there's no defined form for this process or task. If this is an undesired situation please check with your administrator.' 

In the parent process, i have called a subprocess and i have dependency and kbase definitions for that.

Without subprocess call, the workflow is working fine and it's taking up the correct task form. However, if i'm calling subprocess, above warning occurs for task forms and it's automatically generated.

Why is it not taking up the correct task form?

Please help me in resolving this issue.

Thanks
Sudha

Maciej Swiderski

unread,
Mar 1, 2019, 2:11:22 PM3/1/19
to sudha...@gmail.com, jBPM Usage
Frankly speaking not sure… maybe some name clash or so the forms are not resolved at deploy time… if you could provide a reproducer we could have a look though I am not aware of any issues with that.

Maciej

Reply all
Reply to author
Forward
0 new messages