Skip to content

Debugging_the_module_with_eclipse

Etienne Brosse edited this page Jul 6, 2021 · 5 revisions

Debugging the module with Eclipse

In order to have the Eclipse Java debugger run the Module Java code and step through it, the Modelio Modeler application has to be run in the Eclipse IDE.

Therefore, to have the process working smoothly, special attention must be paid to the configuration of Eclipse.

  • As Modelio is based on RCP, you have to deploy the Plug-ins Development Environment (PDE) as plug-in in Eclipse. This is mandatory to set the debug environment. See the PDE project page for more information.

  • A debug configuration has to be defined in Eclipse in order to have the Modelio application run in the Eclipse debugger and to be able to debug the Module Java code.Creation of the debug configuration is a three steps procedure:

    1. Creating a JRE configuration because Modelio provides its own JRE

    2. Creating a target configuration because Modelio is an RCP application

    3. Creating a debug configuration based on the JRE and target configurations.

When the Eclipse IDE has been properly configured, the overall debugging procedure is as follows:

  1. Generate and package the Module in Eclipse using the pom.xml file.

  2. Launch Modelio in the Eclipse debugger.

  3. Open a Modelio test project in which the Module is deployed (deploy it if it is the first time).

  4. In the Eclipse debugger, set up breakpoints in the Module code where useful.

  5. Launch the Module commands to be debugged.

For bug fixing simply do the following:

  1. Edit and fix the code directly in Eclipse.

  2. Re-compile in Eclipse.

  3. Re-run Modelio, re-open the test project.

  4. Test and check the fix.

  5. When done, repackage the module using the pom.xml file.

Creating the JRE configuration

Because Modelio provides its own copy of a standard JRE, it is recommended to use it when debugging Modelio module. Note that it can work with the system standard JRE but sometimes it fails.

Open the preferences window (Window –> Preferences)

image
  1. Select Java / Installed JREs

  2. Click on the Add… button and choose the Standard JVM

  3. Enter the path of Modelio JRE directory. All the required fields will be automatically filled in by Eclipse.

  4. Give a name for the JRE Definition (for example: Modelio)

  5. Click on the Finish button, select the new JRE definition as the active one.

Creating the target configuration

Modelio is RCP based so a specific target configuration is required to debug Modelio module. This target configuration will then be used in the debug configuration. The procedure is as follows:

image
1. Open the preferences window (Window –> Preferences) and select Plug-in Development / Target Plateform (if this entry is not available, it means that PDE should be installed)

  1. Click on the “Add…” button

  2. Select “Nothing: start with an empty target definition” then “Next>” button

  3. On the new dialog, fill in the name with Modelio for example.

  4. Then in the Locations tab, select “Add…” button, then Directory, then select the root directory where Modelio is installed. Then Eclipse automatically adds all the Modelio plug-ins.

  5. Select Finish button
    image

  6. Select the new target definition as the active one.

  7. Click an Apply button

  8. Then click on OK button and we are done with the target configuration for Modelio.

Creating and configuration the debug configuration

Now that the target configuration is defined and activated, prior to run Modelio within Eclipse we should create a debug configuration.

  • Creation
    image

    • Select the menu Run –> Debug Configurations…

    • Create a new Eclipse Application

  • Configuration
    image

    1. Fill in the Name field with something like Modelio debug (1)

    2. Check that the Runtime JRE field is set to Modelio JRE (2)

    3. Fill in the Bootstrap entries field with the installation directory of Modelio (3)

      image
    4. Select the Arguments tab

    5. Fill in the Other field in Working directory frame with the installation directory of Modelio

    6. Click on Apply button

Launching Modelio under Eclipse debugger

To debug your module, follow this process:

  • Run Modelio from the Debug menu of Eclipse (using the launcher created previously)
    image

  • Open a database with the module deployed,

  • Use the module (run its commands, apply its stereotypes, etc.)

When Eclipse runs the configuration, it launches an application from a different working directory (remember, we had to change the location).

The direct consequence is that Eclipse cannot retrieve the source path for our project at first launch when hitting a breakpoint. This is illustrated in the figure below:
image

The solution consists in configuring the edit path and adding a source path.
image

Select a java project source and check the JUnitModule

Note

To be sure that the module Java code is generated with all the options that allow comfortable debugging, the code should be compile with Eclipse compiler, not with javac invoked from the module pom.xml file. If it happens that debugger doesn’t stop at the expected lines, a full recompilation from Eclipse is recommended. To do this:

  • Stop any debugging session

  • Ensure the menu option Project –> Build automatically is ticked

  • Clean the module Java project. Project –> Clean…

  • Wait until Eclipse has recompiled all the source code

  • Then, trigger the packaging of the module


Clone this wiki locally