Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Product and Topic Expert
Product and Topic Expert
0 Kudos

In the previous parts (first and second) of this tutorial, we’ve created a Java bundle and an OData service based on it. And we've verified that the OData service works fine and can be consumed.

Now we’d like to take the opportunity and use Eclipse to debug our Java code.


Part I

1. Prepare SMP server

2. Prepare Eclipse

3. Create the OSGi bundle

    3.1. Create Plug-In project

    3.2. Implement DataProvider class

    3.3. Implement Activator class

    3.4. Deploy the bundle to SMP

    3.5. Verify the deployed bundle

Part II

4. Create the OData service

    4.1. Implement the QUERY operation

    4.2. Adding $skip and $top capability

    4.3. Implement the READ operation

5. Test the OData service

Part III

6. Debug the Java code

    6.1. Start SMP server in debug mode

    6.2. Connect from Eclipse to SMP

    6.3. Debug the Java code in Eclipse

7. Summary

8. Links

Part IV

9. Test the API automatically

    9.1. Create test fragment

    9.2. Create JUnit tests

    9.3. Run the tests

    9.4. Summary

6. Debug the Java code

6.1. Start SMP server in debug mode

In order to be able to debug a bundle that is running in SMP server, we have to start the SMP server in debug mode.

- In case your SMP is already running, stop it

- Open command prompt and navigate to the folder <SMP_install_dir>/Server

  This folder contains a batch file that is used to start the sever and has name go.bat

- On the command prompt, type the following command

go -debug 8000


  This command tells the server to start in debug mode and to listen to connection on port 8000

  Press enter and wait until the following message is printed to the command prompt


6.2. Connect from Eclipse to SMP

After SMP server is up and running, we can connect from Eclipse to the debug-port

From the Eclipse main-menu, go to

Run -> Debug Configurations…

Select “Remote Java Application” and click on the “New” button in the dialog’s tool bar

As a result, a new Launch Configuration is created and the details can be entered.

In the “Connect” tab, we have to

- enter a name for the Launch Configuration, this can be any arbitrary name

- choose the Eclipse-project that we want to debug

- in the “Connection Properties” field, enter the SMP server and the debug port as specified in the previous section

In the “Source”-tab, we have to specify, where the sources that we want to debug, are located.

Press “Add”, select Java Project, then select the project that contains the Java files, in our example it is called com.example.dataprovider

(as we created in the first part of this tutorial)


Actually, in our example, it isn't necessary to manually add the dataprovider-project to the “Source Lookup Path”, because it is already contained in the “Default” folder, because we have specified it as project in the “Connect” tab.

That’s it for the settings of the Launch Configuration, which is automatically saved.

After pressing “Debug”, Eclipse connects to the specified host and port.

In the “Debug” perspective, you can see the connection.

(The "Debug" perspective can be opened via Window->Open Perspective->Other...)

From here, you can use the toolbar button to “disconnect” from the server, i.e. terminate your debug-session.

Note that the Launch Configuration doesn’t start or stop the server, it only launches a connection to the SMP server.

If you get an error message telling that Connection was refused, then you’ve probably forgot to start SMP in debug mode

6.3. Debug the Java code in Eclipse

Now that the SMP server is running in debug mode and Eclipse is connected to it, we can start debugging.

Open the DataProvider class and set some breakpoints, e.g. in the first line of the getAllProducts() method.

Tip: you can place the cursor in the line and then press Ctr+Shift+B

Then open a browser and invoke the ProductSet URL:


Afterwards, change back to Eclipse and you’ll see:

- the execution is paused at the specified position

- the “Variables” View allows to inspect the available objects

- the “Display” View  (open it via Window->Show View) allows to directly type and execute Java statements

- the shortcut Ctrl+Shift+I allows to “inspect” the selected object or statement


This is the magic moment and you should take a breath and enjoy that your dreams have come true…


Up to now, in the series of blogs forming a tutorial illustrating how I like to work in the area of OData services based on Integration Gateway in SMP 3.0, I’ve shown my main points:

- scripting is done in the OData project, but whenever it gets complex, move the code to a separate bundle

- advantages are the enhanced coding support in the editor and the debugging capabilities.

In part 3 (this page), we’ve learned how to debug the code that we’ve written in the bundle.

You may have felt the disadvantage of this way of working: quite some overhead with respect to building and deploying the bundle.

In the last part of this tutorial, we’ll learn how to overcome it.


Installing SMP toolkit in Eclipse:

Tutorial for Integration Gateway:

The series of tutorials about the REST data source. Many implementation details are also relevant for the "Custom Code" data source.

Integration Gateway: REST data source, overview of Blogs

Introduction to “Custom Code” data source: