我已经定义了一个全局异常策略,但是当Mule执行我的Groovy脚本时,它不会执行全局捕获异常策略,而是执行org.mule.exception.DefaultSystemExceptionStrategy。
<!-- Define Global Catch Exception Strategy -->
<catch-exception-strategy name="catchExceptionStrategy">
<logger level="ERROR" message="Component X: #[exception]" doc:name="Logger"/>
<logger level="ERROR" message="Component X: E1_Error Service exited with errors. Please see the error log for details." doc:name="Logger"/>
</catch-exception-strategy>
有没有理由为什么Mule会恢复默认的系统异常策略而不是流程中定义的catch异常策略?
以下提供的日志:
DEBUG 2014-05-15 10:48:46,966 [[processes].returnInputFileConnector.receiver.01] org.mule.api.processor.LoggerMessageProcessor: Component X: Renamed Archived file in archive folder
INFO 2014-05-15 10:48:46,967 [[processes].returnInputFileConnector.receiver.01] org.mule.api.processor.LoggerMessageProcessor: Component X: L3_Done Service completed with no errors.
DEBUG 2014-05-15 10:49:00,030 [scheduler-processes_Worker-1] org.mule.api.processor.LoggerMessageProcessor: Component X: Begin batch process at 20140515104900
ERROR 2014-05-15 10:49:00,254 [scheduler-processes_Worker-1] org.mule.exception.DefaultSystemExceptionStrategy:
********************************************************************************
Message : Failed to invoke ScriptComponent{returnFlow2.component.1473216174}. Component that caused exception is: ScriptComponent{returnFlow2.component.1473216174}. Message payload is of type: AbstractConnector$7
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. error=13, Permission denied (java.io.IOException)
java.lang.UNIXProcess:-2 (null)
2. Cannot run program "/Users/edwchang/integration/.mule/apps/processes/classes/scripts/script.sh": error=13, Permission denied (java.io.IOException)
java.lang.ProcessBuilder:1041 (null)
3. java.io.IOException: Cannot run program "/Users/edwchang/integration/.mule/apps/processes/classes/scripts/script.sh": error=13, Permission denied (javax.script.ScriptException)
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl:323 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/script/ScriptException.html)
4. Failed to invoke ScriptComponent{Flow2.component.1473216174}. Component that caused exception is: ScriptComponent{Flow2.component.1473216174}. Message payload is of type: AbstractConnector$7 (org.mule.component.ComponentException)
org.mule.component.AbstractComponent:148 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
答案 0 :(得分:1)
根据Mule文档here,您的异常似乎在系统级别被抛出:
当抛出异常时,Mule调用系统异常策略 在系统级别(即,当不涉及消息时,异常由系统异常策略处理)。
由于您的异常来自您尝试执行的shell脚本,我相信这会导致此异常策略,因为不涉及Mule消息。
答案 1 :(得分:1)
为了提供全局异常策略,这里是示例代码。
<!-- Define Global Catch Exception Strategy -->
<catch-exception-strategy name="catchExceptionStrategy">
<logger level="ERROR" message="Component X: #[exception]" doc:name="Logger"/>
<logger level="ERROR" message="Component X: E1_Error Service exited with errors. Please see the error log for details." doc:name="Logger"/>
</catch-exception-strategy>
<configuration defaultExceptionStrategy-ref="catchExceptionStrategy" />
因此,如果异常涉及一条消息(即来自流程),那么它将由异常策略处理。 Else Mule的系统异常策略将负责处理它。