2016-12-13 11 views
0

WSO2 ESB 로컬 레지스트리에 저장하고있는 Groovy 스크립트를 실행하려고합니다. 나는 다음과 같은 오류를 받고 있어요 그렇게 할 때 :WSO2 ESB 레지스트리에 저장된 Groovy 스크립트를 실행할 수 없습니다.

 
ERROR {org.apache.synapse.mediators.bsf.ScriptMediator} - The script engine returned a NoSuchMethodException executing the external groovy script : Value {name ='null', keyValue ='file:Scripts/Groovy/test.groovy'} function mediate {org.apache.synapse.mediators.bsf.ScriptMediator} 
java.lang.NoSuchMethodException: No signature of method: com.sun.script.groovy.GroovyScriptEngine.mediate() is applicable for argument types: (org.apache.synapse.mediators.bsf.ScriptMessageContext) values: [[email protected]] 
Possible solutions: wait() 

나는 코드가 인라인 스크립트 중재자에, 모든 확인을 실행 넣어합니다. 중재를위한 Ruby 스크립트 사용 예 : <x><![CDATA[...code...]]></x>과 같은 스크립트 코드를 래핑하려고 시도했습니다. Sample 353: Using Ruby Scripts for Mediation. groovy-all-2.4.7.jar ~ ESB_HOME \ repository \ components \ lib도 추가합니다.

레지스트리에 저장된 Groovy 스크립트를 어떻게 실행할 수 있습니까? 내가 도대체 ​​뭘 잘못하고있는 겁니까?

그루비 스크립트

class Example { 
    static def DisplayName() { 
     println("This is how methods work in groovy"); 
     println("This is an example of a simple method"); 
    } 

    static void main(String[] args) { 
     DisplayName(); 
    } 
} 

프록시 서비스

<proxy name="TestScriptProxy" startOnLoad="true" trace="disable" 
    transports="http https" xmlns="http://ws.apache.org/ns/synapse"> 
    <target> 
    <inSequence> 
     <script language="groovy"><![CDATA[println "This is an in-line script";]]></script> 
     <script function="DisplayName" 
     key="file:Scripts/Groovy/test.groovy" language="groovy"/> 
    </inSequence> 
    <outSequence/> 
    <faultSequence/> 
    </target> 
</proxy> 

ESB 버전이 실행 5.0.0입니다 : 여기

는 그루비 스크립트와 내가 테스트하고있어 프록시, 사랑의입니다 Windows 10.

답변

2

레지스트리에 Groovy 스크립트가있는 경우 원본은 다음과 같아야합니다. 레지스트리 경로. 예 : gov:scripts/Groovy/test.groovy.

파일을 참조하는 경우 ESB_HOME에 상대적인 경로를 지정하십시오. 예를 들어 스크립트 폴더, ESB_HOME 디렉토리에있는 경우 file:scripts/Groovy/test.groovy

먼저 부하 아래 스크립트 파일 :

<localEntry key="DisplayNameScript" src="file:scripts/Groovy/test.groovy"/> 

이제 기능

<script language="groovy" key="DisplayNameScript" function="DisplayName"/> 
에게 전화