Debugging Java Actions
The Mendix Modeler has a built-in debugger to solve errors on 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 utilizing the debugger of Eclipse.
Table of contents
Before you start with this how-to please complete the following prerequisites:
- Install Eclipse
- Add a Java action and open the project in Eclipse.
- Complete the how-to about extending your application with custom Java
- Deploy the application for Eclipse by selecting ‘Deploy for Eclipse’ from the project menu in the Mendix Modeler. You should redo this every time you make changes in the Mendix Modeler.
2. Setting Breakpoints
- Open Eclipse and locate the project in the package explorer.
- Double click the ReverseCustomerName.java in the package explorer of Eclipse.
- Place the cursor on the line that needs debugging.
Hold down Ctrl+Shift and press B to enable a breakpoint. A blue dot in front of the line will occur.
You can also use Ctrl+Shift+B to disable a breakpoint.
3. Debugging in Eclipse
- Select the project root node in the package explorer.
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 do whatever is needed to trigger the Java action.
As an end user of the application you will see progress bar on your application. As a developer you will notice that the Eclipse icon will be flashing on the windows task bar.
- Open Eclipse. You should now see the ‘Debug’ perspective of Eclipse.
Click Step into (F5) or Step over (F6) to move on the next step in the Microflow.
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’ (F7) you can instruct the debugger to leave the function. It’s basically the opposite of ‘Step Into’. Clicking ‘Resume’ (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.