gpt4 book ai didi

java - sun.org.mozilla.javascript.internal.EcmaError : ReferenceError

转载 作者:行者123 更新时间:2023-11-30 00:02:12 24 4
gpt4 key购买 nike

我已在 xml 文件中创建了流程定义。在此过程中,我有一个步骤应该将数据插入 mysql 数据库,但是当我运行代码时,出现以下错误:

Exception in thread "main" org.activiti.engine.ActivitiException: problem evaluating
script: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError:"ReportingUtil"is
not defined.(<Unknown source>#7) in <Unknown source> at line number
at
org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:89)
...
Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError:
ReferenceError: "ReportingUtil" is not defined. (<Unknown source>#7) in <Unknownsource>
at
line number 7
at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
...

我从 java 类启动我的流程引擎。

这是我的流程定义:

  <?xml version="1.0"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="http://activiti.org/bpmn20" id="definitions">
<process id="simpleEmailProcess" name="simple email">
<startEvent id="theStart"/>
<sequenceFlow id="flow1" targetRef="sendMail" sourceRef="theStart"/>
<sequenceFlow id="flow2" targetRef="waitState" sourceRef="sendMail"/>
<serviceTask id="sendMail" activiti:class="org.mywebbapp.activiti.RiskProcess"
activiti:type="mail">
<extensionElements>
<activiti:field name="from" stringValue="workflowact@gmail.com"/>
<activiti:field name="to" expression="${recipient}"/>
<activiti:field name="subject" expression="Are you responsible for risk ${riskID}?"/>
<activiti:field name="html">
<activiti:expression>
<![CDATA[ <html> <body> Hello ${name},<br/><br/> Are you responsibible for risk
${riskID}? Please reply to this email by either Y/N.<br/><br/> Kind regards,<br/>
The company. </body> </html> ]]>
</activiti:expression>
</activiti:field>
</extensionElements>
</serviceTask>
<receiveTask id="waitState" name="wait" />

<scriptTask id="generateDataset" name="Execute script" scriptFormat="JavaScript" activiti:autoStoreVariables="false">
<script><![CDATA[

importPackage(java.sql);
importPackage(java.lang);
importPackage(org.activiti.explorer.reporting.ReportUtil);

ReportingUtil.executeSelectSqlQuery("insert into risk values ('123', 'user@gmail.com', 'Y')");
]]></script>
</scriptTask>
<sequenceFlow id="flow3" targetRef="generateDataset" sourceRef="waitState"/>
<sequenceFlow id="flow4" targetRef="theEnd" sourceRef="generateDataset"/>
<endEvent id="theEnd"/>

我在这里读过关于需要使用绑定(bind)吗?有什么建议吗?

谢谢

最佳答案

importPackage(org.activiti.explorer.reporting.ReportUtil);

您正在尝试import一个类作为一个包。使用importClass

我假设使用 Java 8 和 Nashorn。

关于java - sun.org.mozilla.javascript.internal.EcmaError : ReferenceError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24927496/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com