DMN: ClassCastException when parsing decision

173 views
Skip to first unread message

Andre Hegerath | HBT

unread,
Nov 17, 2015, 7:34:38 AM11/17/15
to camunda-...@googlegroups.com
Hi all,

when playing around for the first time with Camunda’s rule engine implementation in the latest 7.4.0-SNAPSHOT, I encounter the following exception:

Exception in thread "main" org.camunda.bpm.dmn.engine.impl.transform.DmnTransformException: DMN-02004 Error while transforming decisions: org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl cannot be cast to org.camunda.bpm.model.dmn.instance.Definitions
at org.camunda.bpm.dmn.engine.impl.transform.DmnTransformLogger.errorWhileTransforming(DmnTransformLogger.java:55)
at org.camunda.bpm.dmn.engine.impl.transform.DefaultDmnTransform.transformDecisions(DefaultDmnTransform.java:137)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngine.parseDecisions(DefaultDmnEngine.java:62)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngine.parseDecision(DefaultDmnEngine.java:117)
at DecisionStarter.main(DecisionStarter.java:27)
Caused by: java.lang.ClassCastException: org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl cannot be cast to org.camunda.bpm.model.dmn.instance.Definitions
at org.camunda.bpm.model.dmn.impl.DmnModelInstanceImpl.getDefinitions(DmnModelInstanceImpl.java:31)
at org.camunda.bpm.dmn.engine.impl.transform.DefaultDmnTransform.transformDecisions(DefaultDmnTransform.java:124)
... 3 more


I use the following code to setup the rule engine and run a rule evaluation on it, inspired by the code in Bernd's post: https://groups.google.com/d/msg/camunda-bpm-users/Z2bKes3nIA0/64e24b8FCgAJ

String chargeType = "CC";
Integer freightChargeValue = 15000;
Map<String, Object> variables = Variables.createVariables();
variables.put("chargeType", chargeType);
variables.put("freightChargeValue", freightChargeValue);

LOGGER.debug("Initializing DMN engine");
DmnEngine dmnEngine = new DefaultDmnEngineConfiguration().buildEngine();
DmnDecision decision = dmnEngine.parseDecision("manualCheckNeeded.dmn",
DecisionStarter.class.getResourceAsStream("/manualCheckNeeded.dmn"));
DmnDecisionTableResult decisionResult = dmnEngine.evaluateDecisionTable(decision, variables);


Does anyone have an idea what do I miss to get it running? If needed, I could provide the Eclipse project (but it contains barely more than the Java class, the Maven POM and the attached .dmn file which I created with the dmn-io modeller).

Thanks,
Andre



Andre Hegerath
IT-Systementwickler

E-Mail: andre.h...@hbt.de
Tel.: +49 40 369779-21

HBT Hamburger Berater Team GmbH
Stadthausbrücke 3, 20355 Hamburg

Geschäftsführer:
Ilse Habermann, Hans-Joachim Habermann,
Arne Habermann, Daniel Hoffmann

Handelsregister:
HRB 31629 Hamburg
manualCheckNeeded.dmn

Sebastian Menski

unread,
Nov 17, 2015, 8:03:11 AM11/17/15
to camunda BPM users, Andre.H...@hbt.de
Hi Andre,

the problem is that we switched to DMN 1.1 since the latest alpha. With DMN 1.1 the XML representation changed. So the files produced by https://camunda.org/dmn/demo/ can only be used up to 7.4.0-alpha2.
If you want to create files for 7.4.0-SNAPSHOT please use https://camunda.org/dmn/demo-stage/ which is the latest version of the modeler.

Cheers,
Sebastian

Andre Hegerath | HBT

unread,
Nov 17, 2015, 9:20:41 AM11/17/15
to camunda-...@googlegroups.com


Oh, I was not aware of the DMN demo stage - with a new .dmn file which is created with that modeler version everything works fine :-)


Great work, thanks!


Andre



Von: Sebastian Menski <sebastia...@camunda.com>
Gesendet: Dienstag, 17. November 2015 14:03
An: camunda BPM users
Cc: Andre Hegerath | HBT
Betreff: [SPAM] Re: DMN: ClassCastException when parsing decision
 
Reply all
Reply to author
Forward
0 new messages