【问题标题】:Exception while running Apache SCXML engine. Argument type mismatch -运行 Apache SCXML 引擎时出现异常。参数类型不匹配 -
【发布时间】:2013-11-08 07:14:46
【问题描述】:

我正在使用 apache commons scxml 引擎运行 Microwave oven 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 节点,

【问题讨论】:

  • 您解决了吗?我刚刚遇到了同样的问题。

标签: java apache-commons scxml apache-commons-scxml


【解决方案1】:

我发现了一些应该有所帮助的东西:

  • Apache commons-scxml 不喜欢&lt;scxml&gt; 标签中的datamodel="ecmascript" 属性;别管它。
  • 在查看 JEXL 评估程序源之前,我在使用 &lt;assign&gt; 表达式时遇到了问题;当我从 location 切换到 name 时,它似乎有效:

<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="init"
<datamodel>
  <data id="loop_ctr" expr="0"/>
</datamodel>
...
<state id="in_progress">
  <onentry>
    <assign name="loop_ctr" expr="loop_ctr + 1"/>
  </onentry>
  <transition event="complete" target="in_review"></transition>
</state>
...

【讨论】:

    猜你喜欢
    • 2016-12-18
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 2017-08-15
    • 2014-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多