我正在尝试在 Mule Flow 中执行 groovy 脚本。
使用版本Mule Server 3.5.1.EE..
我已经将 groovy-all.jar 包含在类路径中
Groovy 脚本内容很简单
return "demo payload"
执行时我得到以下异常堆栈跟踪
java.lang.NullPointerException
at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:108)
at org.mule.component.AbstractComponent.process(AbstractComponent.java:152)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
如果我需要发布更多详细信息,请告诉我。
任何帮助将不胜感激。
最佳答案
我不确定您是否理解正确,但在 Mule 流程中正确使用 Groovy 如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<mule ...>
<flow name="lab1Flow1" doc:name="lab1Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA["demo payload"]]></scripting:script>
</scripting:component>
</flow>
</mule>
如果您使用curl 尝试上面的流程,它应该会响应(如预期):
$ curl -i http://localhost:8081
HTTP/1.1 200 OK
Date: Sun, 07 Dec 2014 16:52:48 +0000
Server: Mule EE Core Extensions/3.5.2
X-MULE_SESSION: ...
X-MULE_ENCODING: UTF-8
Content-Type: text/plain
Content-Length: 12
Connection: close
demo payload
关于java - Mule 流中的 Groovy 脚本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25564799/