Debug Java Actions
Introduction
Mendix Studio Pro has a built-in debugger to solve errors on the microflow level. A microflow can be extended with custom Java actions, but because these actions are text-based, they can only be checked on compile errors. If you run into an error in any of the Java actions, you can easily debug them by utilizing the debugger of Eclipse.
This how-to teaches you how to do the following:
- Set breakpoints
- Debug in Eclipse
Prerequisites
Before starting this how-to, make sure you have completed the following prerequisites:
- Install Eclipse
- Add a Java action and open the app in Eclipse
- Read Extending Your Application with Custom Java
- Deploy the application for Eclipse by selecting Deploy for Eclipse from the app menu in Studio Pro (you should redo this every time you make changes in Studio Pro):
Setting Breakpoints
- Open Eclipse and locate the app in the Package Explorer.
- Double-click ReverseCustomerName.java:
- Place the cursor on the line that needs debugging, press Ctrl + Shift + B to enable a breakpoint. A blue dot in front of the line will appear:
You can also use Ctrl + Shift + B to disable a breakpoint.
Debugging in Eclipse
-
Select the app root node in the package explorer and click the debug icon in the Eclipse toolbar:
The application will now be started with Eclipse attached as debugger.
-
As soon as the deployment process is ready, open the application in your browser and trigger the Java action:
- As an end-user of the application, you will see a progress bar on your application
- As a developer, you will see the Eclipse icon flashing on the Windows task bar
-
Open Eclipse. You should now see the “debug” perspective of Eclipse.
-
Click Step into (or press F5) or Step over (or press F6) to move on the next step in the microflow:
With debugger options, the difference between Step into and Step over is only noticeable if you run into a function call. Step into means that the debugger steps into the function, and Step over just moves the debugger to the next line in the same Java action. With Step return (pressing F7), you can instruct the debugger to leave the function; this is basically the opposite of Step into. Clicking Resume (pressing F8) instructs the debugger to continue until it reaches another breakpoint. -
Place your cursor on any of the variables in the Java action to see its value in a pop-up window:
A current limitation is that local variables may not be visible when debugging Java actions in Eclipse. This can affect your ability to inspect variable values during execution.
Read More
- Find the Root Cause of Runtime Errors
- Clear Warning Messages in Mendix
- Test Web Services Using SoapUI
- Monitor Mendix Using JMX
- Debug Java Actions Remotely
- Log Levels
- Debugging Microflows and Nanoflows
- Debugging Microflows Remotely
- Java Actions