Im running the Microwave oven scxml with apache commons scxml engine. I have my Custom class that extends the AbstarctStateMachine
public class MicrowaveOwenStateMachine extends AbstractStateMachine {
public MicrowaveOwenStateMachine() {
super(MicrowaveOwenStateMachine.class.getClassLoader().getResource("mOwen.xml"));
}
public State getCurrentState() {
Set<?> states = getEngine().getCurrentStatus().getStates();
return ( (State) states.iterator().next());
}
public void oven(){
System.out.println("State :oven");
}
public void engine(){
System.out.println("State : Engine");
}
public void off(){
System.out.println("State : off");
}
public void on(){
System.out.println("State : on");
}
public void idle(){
System.out.println("State : Idle");
}
public void cooking(){
System.out.println("State : Cooking");
}
public void door(){
System.out.println("State : Door");
}
public void closed(){
System.out.println("State : Closed");
}
public void open(){
System.out.println("State : Open");
}
}
Now when creating an instance of this class ,im getting an exception
java.lang.IllegalArgumentException: Cannot invoke org.apache.commons.scxml.model.SCXML.setDatamodel on bean class 'class org.apache.commons.scxml.model.SCXML' - argument type mismatch - had objects of type "java.lang.String" but expected signature "org.apache.commons.scxml.model.Datamodel"
at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2235)
at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2151)
at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1957)
at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:2064)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1017)
at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:830)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:433)
at org.apache.commons.digester.SetPropertiesRule.begin(SetPropertiesRule.java:252)
at org.apache.commons.digester.Rule.begin(Rule.java:175)
at org.apache.commons.digester.Digester.startElement(Digester.java:1464)
at
I know that its something to do with my datamodel as the datamodel is not taken as an XML node,
I discovered a couple of things that should help:
datamodel="ecmascript"
attribute in the<scxml>
tag; leave it out.<assign>
expressions until I looked at the JEXL evaluator source; it seems to work when I switched fromlocation
toname
: