Contact Us 1-800-596-4880

Debugging Mule Applications

logo cloud IDE Cloud IDE

logo desktop IDE Desktop IDE

Open Beta Release: The cloud IDE is in open beta. Any use of Anypoint Code Builder in its beta state is subject to the applicable beta services terms and conditions, available from the IDE.

Debug your Mule application using the embedded debugger in Anypoint Code Builder.

The process for debugging a Mule app is:

  1. Set breakpoints to pause the execution of a flow at lines that you want to inspect or fix.

    Breakpoints are markers that you add on line numbers in a configuration XML file for a Mule application that you are developing.

  2. Run the application in debug mode.

  3. Start execution of a flow in your Mule application.

    For example, trigger an HTTP Listener or configure a Scheduler component.

  4. When the execution stops at a breakpoint, use the debug toolbar to navigate, inspect, and fix issues.

  5. After addressing an issue at a breakpoint, redeploy (hot deploy) the running instance of your application.

  6. Execute your flow again, and continue debugging until you address all issues.

  7. Stop the debug session.

Debug Console Overview

Elements of the debugger view
1 Start Debugging: Starts an instance of a Mule application in debugging mode.
2 Debug Toolbar: Controls debugging of Mule applications.
3 Variables panel: Provides Mule event and parameter data.

The Mule event includes message payload and attribute details, as well as Mule variable data. The parameters include component data, such as the component name.

4 Run and Debug (MuleSoft) icon: Opens the Run and Debug panel, where you can click Start Debugging (F5) and find debugging information.

Keyboard shortcut: Cmd+Shift+d (Mac) or Ctrl+Shift+d (Windows)

5 Watch panel: Helps you evaluate variables and expressions.
6 Call Stack panel: Identifies the functions or procedures that are currently in the stack.
7 Breakpoints panel: Lists all breakpoints in your Mule application.
8 Terminal console: Displays the output of the Maven build process and the results of the deployment to the embedded Mule Runtime engine.
9 Breakpoint icon: Identifies a line in the configuration XML to pause execution of the flow so that you can check for and fix any issues.

Add a Breakpoint

A breakpoint enables you to pause your Mule application at a specific place to learn more about what is happening.

To add a breakpoint to your Mule application:

  1. In Anypoint Code Builder, on the Explorer view, open your configuration XML file, for example, my-project-name.xml.

  2. Open the Run and Debug panel.

    Show me how
    • Click the (Run and Debug) icon in the activity bar.

    • Use the keyboard shortcuts:

      • Mac: Cmd+Shift+d

      • Windows: Ctrl+Shift+d

    • In the desktop IDE, select View > Run.

    • In the cloud IDE, click the (menu) icon, and select View > Run.

  3. Click the line number in your <flow-ref> component to add a breakpoint on that component:

    Add breakpoint on a line number

    You can also use F9 to add a breakpoint to the current line.

  4. In your configuration XML file, add two more breakpoints for the <db:select> and the <set-variable> components.

All breakpoints appear in the Breakpoints panel:

Breakpoints panel

Run Your Application in Debug Mode

After setting up your debug conditions, run a debug session and evaluate your Mule application at each breakpoint:

  1. Open the Run and Debug panel.

    Show me how
    • Click the (Run and Debug) icon in the activity bar.

    • Use the keyboard shortcuts:

      • Mac: Cmd+Shift+d

      • Windows: Ctrl+Shift+d

    • In the desktop IDE, select View > Run.

    • In the cloud IDE, click the (menu) icon, and select View > Run.

  2. Click the (Start Debugging (F5)) icon for Debug Mule Application.

    Alternatively, if the Start Debugging (F5) icon is not present:

    1. Click Run and Debug.

    2. If a Select debugger dropdown menu appears, select Mule Xml Debugger to initiate the debugging session:

      Run and Debug button and Mule XML Debugger menu item

      When the application deploys successfully, you see a DEPLOYED log message in the output panel:

      **********************************************************************
      *              - - + DOMAIN + - -               * - - + STATUS + - - *
      **********************************************************************
      * default                                       * DEPLOYED           *
      **********************************************************************
Selecting Run > Start without Debugging produces an error.

Anypoint Code Builder packages your application and deploys the application to the embedded Mule runtime engine. A terminal opens so you can view the status:

Debugging status in a terminal window

The terminal displays a message and the status bar turns red to indicate that the application is running.

Use buttons on the debug toolbar to control debugging of Mule applications.

Debug Toolbar

Debug toolbar
1 Continue F5

Proceeds to the next breakpoint, if present, and pauses execution of the application. Otherwise, continues to the end of the application.

2 Step Over F10

Proceeds to the next component in the flow, where execution pauses. At a Flow Ref component (<flow-ref/>), clicking Step Over proceeds to the next component in the flow but does not follow the Flow Ref logic to a referenced flow or proceed to another flow.

Step Over Details

Configuration XML example:

<flow name="flow1" doc:name="Flow" >
  <http:listener path="greet" config-ref="HTTP_Listener_config" doc:name="Listener"/>
  <flow-ref name="myNewFlow" /> (1)
  <logger doc:name="Logger1" message="test1"/> (2)
</flow>

<flow name="flow2" doc:name="Flow" >
  <logger doc:name="Logger2" message="test2"/>
</flow>

Step Over behavior:

1 Skips <flow-ref/> logic
2 Reaches <logger/> named Logger1
3 Step Into F11

Proceeds to the next component in the flow, where execution pauses. At a Flow Ref component (<flow-ref/>), clicking Step Into follows the logic of the component and proceeds to the first component in the referenced flow. If a component in a flow follows a Flow Ref component, Step Into returns to that component after the last component in the referenced flow (or flows).

Step Into Details

Configuration XML example:

<flow name="flow1" doc:name="Flow" >
  <http:listener path="greet" config-ref="HTTP_Listener_config" doc:name="Listener"/>
  <flow-ref name="myNewFlow" /> (1)
  <logger doc:name="Logger1" message="test1"/> (3)
</flow>

<flow name="myNewFlow" doc:name="Flow" >
  <logger doc:name="Logger2" message="test2"/> (2)
</flow>

Step Into behavior:

1 Enters <flow-ref/> to follow logic to myNewFlow
2 Reaches Logger2 in next flow, myNewFlow
3 Returns to flow flow1 to reach Logger1
4 Step Out Shift+F11

Exits the current flow and attempts to return to a previous flow. If a previous flow doesn’t exist, the debugger behaves like Continue.

5 Restart Shift+Cmd+F5 (Mac) or Shift+Ctrl+F5 (Windows)

Stop and restart the application without packaging new dependencies, such as new connector dependencies in your pom.xml file.

6 Stop Shift+F5

Stop execution of the application. The next debugging session that you start packages the application with any new dependencies.

Perform a Hot Deploy When Debugging

As you debug your application, periodically perform a hot deployment. A hot deployment updates a running instance of your application but does not package new dependencies, such as new connector dependencies in your pom.xml.

To perform a hot deploy:

  1. Ensure your Mule application is running in the IDE.

  2. Make an update to your application.

  3. Click the Save and Hot-deploy to Mule Runtime (lightning) icon to deploy the application with the change:

    Hot-deploy (lightning) icon in a running Mule application

Stop a Debug Session

To stop your debug session, in the Run and Debug panel, click the (Stop) icon.

The status bar no longer indicates that the application is running.