我正在使用 apache commons scxml 引擎运行微波炉 scxml 。我有扩展 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");
}
}
现在当创建这个类的一个实例时,我得到一个异常
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
我知道这与我的数据模型有关,因为数据模型不被视为 XML 节点,