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)
********************************************************************************
It would appear that your exception is being thrown at the system-level, according to the Mule documentation here:
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.
In order to provide a global exception strategy here is the sample code.
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.