1

我正在尝试在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)

让我知道是否需要发布更多详细信息。
任何帮助,将不胜感激。

4

2 回答 2

1

我不确定您是否正确,但在 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
于 2014-12-07T17:09:09.013 回答
0
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="groovydemoFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
        <scripting:component doc:name="Groovy">
            <scripting:script engine="Groovy"><![CDATA[println('demo payload');]]></scripting:script>
        </scripting:component>
    </flow>
</mule>

Please  try this
于 2016-06-09T10:20:41.803 回答