Exception when referencing a template key (using @{TemplateKey}) in the replaceAll function in a DRL

Updated 2019-08-06T02:34:16+00:00

Issue

We're seeing an error when we try to use a template key (using @{TemplateKey}) in the replaceAll function in a DRL.

e.g.

when
 ...
then
    String $YearExtracted = $Year.replaceAll("@{$YearRegex}", "$2");
...

The UI has an error pop up with just the number "1".

Error on GUI

Here is an exception in server.log.

10:58:48,916 ERROR [org.kie.workbench.common.services.backend.builder.core.Builder] (default task-184) 1: java.lang.ArrayIndexOutOfBoundsException: 1
    at org.drools.workbench.models.guided.template.shared.TemplateModel.getTableAsArray(TemplateModel.java:190)
    at org.drools.workbench.models.guided.template.backend.RuleTemplateModelDRLPersistenceImpl.chooseDataProvider(RuleTemplateModelDRLPersistenceImpl.java:662)
    at org.drools.workbench.models.guided.template.backend.RuleTemplateModelDRLPersistenceImpl.marshal(RuleTemplateModelDRLPersistenceImpl.java:553)
    at org.drools.workbench.models.guided.template.backend.GuidedRuleTemplateProviderImpl.loadFromInputStream(GuidedRuleTemplateProviderImpl.java:34)
    at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.templateToPackageDescr(KnowledgeBuilderImpl.java:524)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl$ResourceToPkgDescrMapper.lambda$static$1(CompositeKnowledgeBuilderImpl.java:324)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildResource(CompositeKnowledgeBuilderImpl.java:199)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:188)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:108)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:100)
    at org.drools.compiler.kie.builder.impl.KieBuilderSetImpl.buildChanges(KieBuilderSetImpl.java:152)
    at org.drools.compiler.kie.builder.impl.KieBuilderSetImpl.build(KieBuilderSetImpl.java:94)
    at org.kie.workbench.common.services.backend.builder.core.Builder.buildIncrementally(Builder.java:533)
    at org.kie.workbench.common.services.backend.builder.core.Builder.addResource(Builder.java:354)
    at org.kie.workbench.common.services.backend.builder.core.Builder.updateResource(Builder.java:419)
    at org.kie.workbench.common.services.backend.validation.asset.ValidatorBuildService.doValidation(ValidatorBuildService.java:135)
    at org.kie.workbench.common.services.backend.validation.asset.ValidatorBuildService.validate(ValidatorBuildService.java:75)
    at org.kie.workbench.common.services.backend.validation.asset.ValidatorBuildService$Proxy$_$$_WeldClientProxy.validate(Unknown Source)
    at org.kie.workbench.common.services.backend.validation.asset.DefaultGenericKieValidator.validate(DefaultGenericKieValidator.java:49)
    at org.kie.workbench.common.services.backend.validation.asset.DefaultGenericKieValidator$Proxy$_$$_WeldClientProxy.validate(Unknown Source)
    at org.drools.workbench.screens.guided.template.server.GuidedRuleTemplateEditorServiceImpl.validate(GuidedRuleTemplateEditorServiceImpl.java:300)
    at org.drools.workbench.screens.guided.template.server.GuidedRuleTemplateEditorServiceImpl.validate(GuidedRuleTemplateEditorServiceImpl.java:62)
    at org.drools.workbench.screens.guided.template.server.GuidedRuleTemplateEditorServiceImpl$Proxy$_$$_WeldClientProxy.validate(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

Environment

  • Red Hat Decision Manager
    • 7.3.1

Subscriber content preview. For full access to the Red Hat Knowledgebase, please log in.

Not a subscriber? Learn more about the benefits of Red Hat Subscriptions.