2014-08-29 74 views
0

我想執行常規腳本騾子流
使用版本騾服務器3.5.1.EE .. 我已經包含在類路徑Groovy的all.jar在騾流Groovy腳本不工作

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) 

讓我知道我是否需要發佈更多細節。
任何幫助,將不勝感激。

+0

對於我這個問題似乎還不清楚。我不知道答案,但不相信groovy腳本只包含return語句。 – Opal 2014-08-29 08:54:23

+0

我相信它是一個有效的腳本。然而,只是爲了再次驗證..我試着運行[這個腳本](http://groovy.codehaus.org/Greedy+Coin+Changer+in+Groovy)以及。我得到了同樣的錯誤..我相信問題不是在腳本中,但在騾子端配置。 – harrybvp 2014-08-29 08:58:05

+3

你可以分享整個騾子流量,這樣的問題可以檢測 – 2014-08-29 09:23:47

回答

1

我不知道,如果你有這個權利,但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 -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 
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