Deep dive into a Mule stack trace example



In our previous post, we had a look at what Stack Traces are and how to use them in Mule. In this post, we will see an example of a Stack Trace to put all of that in practice.

Let’s analyze this stack trace from a mule app:

ERROR 2023-08-21 12:45:32,456 [[myApp].myFlow.processing.worker.01] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message : Execution of the expression resulted in an error. (org.mule.weave.v2.exception.ExpressionEvaluationException).
Element : /myFlow/processors/2 @ myApp:myFlow/processors/2
Element DSL Type : transform
Error type : MULE:EXPRESSION
Error description : Execution of the expression "payload.customer.id" failed.
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.weave.v2.expression.BinaryFieldReferenceExpression.evaluate(BinaryFieldReferenceExpression.java:82)
at org.mule.weave.v2.expression.DefaultWeaveExpressionExecutor.evaluate(DefaultWeaveExpressionExecutor.java:56)
at org.mule.runtime.core.internal.processor.ExpressionMessageProcessor.process(ExpressionMessageProcessor.java:67)
at org.mule.runtime.core.internal.processor.InterceptingChainLifecycleAwareObject$ProcessPhaseExecution.process(InterceptingChainLifecycleAwareObject.java:112)
at org.mule.runtime.core.internal.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:61)
...

These are the different components we can identify:

Error Timestamp and Thread Information:

ERROR 2023-08-21 12:45:32,456 [[myApp].myFlow.processing.worker.01]
  • ERROR: Indicates the log level. Here, it's an error.
  • Timestamp: 2023-08-21 12:45:32,456 shows the exact date and time when the error occurred.
  • Thread: [[myApp].myFlow.processing.worker.01] identifies the thread that was executing when the error occurred. In this case, it's a worker thread associated with the flow myFlow in the myApp application.

Error Handling Component:

org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:

This p
art indicates that the OnErrorPropagateHandler is the Mule component responsible for handling and propagating the error within the flow.
  • Message:
Message: Execution of the expression resulted in an error. (org.mule.weave.v2.exception.ExpressionEvaluationException).
  • Message: Describes the nature of the error. Here, it indicates that an error occurred during the execution of a DataWeave expression.
  • Exception Type: (org.mule.weave.v2.exception.ExpressionEvaluationException) shows the specific type of exception that was thrown.

Flow Element Details:

Element               : /myFlow/processors/2 @ myApp:myFlow/processors/2
Element DSL Type : transform
  • Element: /myFlow/processors/2 refers to the specific component within the myFlow where the error occurred. The number 2 suggests it’s the second processor in the flow.
  • Element DSL Type: transform indicates that this element is a transformation component, likely a DataWeave script.

Error Type and Description:

Error type            : MULE:EXPRESSION
Error description : Execution of the expression "payload.customer.id" failed.
  • Error Type: MULE:EXPRESSION classifies the type of error, showing it relates to an expression evaluation failure.
  • Error Description: Provides more details on what went wrong—specifically, it failed while trying to access payload.customer.id.


Root Exception Stack Trace:

java.lang.NullPointerException
at org.mule.weave.v2.expression.BinaryFieldReferenceExpression.evaluate(BinaryFieldReferenceExpression.java:82)
at org.mule.weave.v2.expression.DefaultWeaveExpressionExecutor.evaluate(DefaultWeaveExpressionExecutor.java:56)
at org.mule.runtime.core.internal.processor.ExpressionMessageProcessor.process(ExpressionMessageProcessor.java:67)
...
Root Exception: java.lang.NullPointerException is the underlying Java exception that caused the issue. It typically occurs when the code attempts to use an object reference that has not been initialized (i.e., it’s null).

Stack Frames:
  • First Frame: at org.mule.weave.v2.expression.BinaryFieldReferenceExpression.evaluate(BinaryFieldReferenceExpression.java:82)shows that the exception occurred in the evaluate method of BinaryFieldReferenceExpressionclass at line 82.
  • Subsequent Frames: These show the sequence of method calls leading up to the error. They include MuleSoft internals such as DefaultWeaveExpressionExecutor.evaluate, ExpressionMessageProcessor.process, and others. Each frame provides the class and method where the error propagated, along with the line number.


In summary

In this stack trace, the active stack frames represent the sequence of method calls that were actively being executed when the error occurred:
  1. BinaryFieldReferenceExpression.evaluate: This method call failed due to a NullPointerException, indicating that it attempted to access or use an object that was null.
  2. DefaultWeaveExpressionExecutor.evaluate: This method invoked the evaluation logic where the exception occurred.
  3. ExpressionMessageProcessor.process: This frame shows the processing logic within MuleSoft that was trying to handle the DataWeave expression.
These stack frames provide a clear path of execution, starting from the point of failure and moving up the chain to where the initial method was called in the Mule application.
Previous Post Next Post