JBoss.orgCommunity Documentation

Chapter 3. Debugging rules

3.1. Creating Breakpoints
3.2. Debugging

This chapter describes how to debug rules during the execution of your Drools application.

At first, we'll focus on how to add breakpoints in the consequences of your rules.

Whenever such a breakpoint is uncounted during the execution of the rules, the execution is halted. It's possible then inspect the variables known at that point and use any of the default debugging actions to decide what should happen next (step over, continue, etc). To inspect the content of the working memory and agenda the Debug views can be used.

You can add/remove rule breakpoints in .drl files in two ways, similar to adding breakpoints to Java files:


The Debug perspective contains a Breakpoints view which can be used to see all defined breakpoints, get their properties, enable/disable or remove them, etc. You can switch to it by navigating to Window > Perspective > Others > Debug.

Drools breakpoints are only enabled if you debug your application as a Drools Application. To do this you should perform one of the actions:


  • Alternatively, you can also go to Debug As > Debug Configuration to open a new dialog for creating, managing and running debug configurations.

    Select the Drools Application item in the left tree and click the New launch configuration button (leftmost icon in the toolbar above the tree). This will create a new configuration and already fill in some of the properties (like the Project and Main class) based on main class you selected in the beginning. All properties shown here are the same as any standard Java program.


Tip:

Remember to change the name of your debug configuration to something meaningful.

Next click the Debug button on the bottom to start debugging your application.

After enabling the debugging, the application starts executing and will halt if any breakpoint is encountered. This can be a Drools rule breakpoint, or any other standard Java breakpoint. Whenever a Drools rule breakpoint is encountered, the corresponding .drl file is opened and the active line is highlighted. The Variables view also contains all rule parameters and their value. You can then use the default Java debug actions to decide what to do next (resume, terminate, step over, etc.). The debug views can also be used to determine the contents of the working memory and agenda at that time as well (you don't have to select a working memory now, the current executing working memory is automatically shown).