Global Catch Exception Strategy is not used

烈酒焚心 提交于 2019-12-25 01:49:23

问题


I have defined a global exception strategy, but when Mule executes my Groovy script it does not execute the Global Catch Exception Strategy, but rather executes the 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>

Is there a reason why Mule would revert to the default system exception strategy rather than the catch exception strategy defined in the flow?

Log provided below:

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)
********************************************************************************

回答1:


It would appear that your exception is being thrown at the system-level, according to the Mule documentation here:

Mule invokes a System Exception Strategy when an exception is thrown at the system-level (i.e., when no message is involved, exceptions are handled by system exception strategies).

Since your exception has come from the shell script your trying to execute, I believe it's resulting to this exception strategy because no Mule message is involved.




回答2:


In order to provide a global exception strategy here is the sample code.

    <!-- 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" />

So, if the exception involves a message (i.e from a flow ) then it will be handled by exception strategy. Else Mule's System Exception Strategy will take care of it.



来源:https://stackoverflow.com/questions/23674605/global-catch-exception-strategy-is-not-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!