Skip to content

3.5 Debugging

SBI- edited this page Oct 14, 2018 · 2 revisions
  • How to attach the debugger
  • limitations of hot loading

A Java debugger can be attached to a running instance of the jazz development environment, in order to set breakpoints etc. This section demonstrates how to attach the IntelliJ Debugger to a running instance of the jazz development environment.

Before we start, launch a run time by any of the documented means, such as creating a run task as demonstrated in using intellij

This example will again use the plugin created in the plugins section. If you haven't followed those instructions, we highly recommend you do so before continuing here.

Attaching

The jazz development environment can be debugged by attaching a remote debugger.

Debug configuration

  1. Go to Run -> Edit Configurations
  2. Add a new configuration by pressing the plus button in the upper left hand corner
  3. Select the remote debugging template

Remote debugging template

  1. Give your new debugging configuration a sensible name, check the Single instance only checkbox and make sure to set the port to 9999

Remote debugging configuration

Save your new debug configuration by hitting OK

  1. You can now go to Run -> Debug 'Debug Jazz Development Environment' to attach IntelliJ to the running Jazz instance. After successfully attaching, the debug view at the bottom of the screen should appear:

IntelliJ debug view

For a full guide to debugging in IntelliJ, please refer to the Jetbrains Debugging Manual.

Break point

  1. We can set break points, for example by clicking in the margin next to the line numbers in the editor.

Setting a break point

Or by pressing Ctrl + F8 with the cursor on the line.

  1. Once the break point is set, we have to make sure to hit it. In the case of our example, we can navigate to the url of our service: https://localhost:7443/jazz/service/org.jazzcommunity.environmentdemo.IEnvironmentDemonstrationService/helloWorld. You will notice that the website doesn't finish loading. That is because IntelliJ has paused execution at the break point.

Halted state

  1. To continue execution, you can press the Resume Program button, or hit F9.

Resume program

For a full guide to debugging in IntelliJ, please refer to the Jetbrains Debugging Manual.

Hot Reload

The provided development environment supports a few hot reloading features. This means that some changes to your code do not require the server to be restarted. Instead, freshly compiled class files are automatically loaded again at run time. There are limitations to this procedure, such as not being able to load new methods, or other structural changes to classes etc., but it is a neat way of enhancing existing code at run time.

  1. Hot reload is automatically enabled, but you need to attach the debugger first.
  2. To demonstrate the functionality, let's first change some code. Press Ctrl + N and start typing the class name to navigate to the HelloWorldService class. This is where we previously set the break point.
  3. Change the output on line 26 to be of a different string value:
writer.write("This will hot reload!");
  1. Rebuild the project by going to Build -> Build Project (or hit Ctrl + F9).
  2. After compiling, IntelliJ will inform you of hot-reload capable changes:

Hot reload changes

Confirm hot reload by pressing Yes

  1. Once the classes have been replaced, you will be notified by a notification at the bottom of your screen:

Hot reload notification

  1. If you reload the website now, you will see a different text.

Clone this wiki locally