Remote Debugging SAP Hybris using Eclipse

logos-014__2_.png

Overview

In this article, we'll cover how to debug the SAP Hybris application remotely using Eclipse.   

Start Hybris in Debug Mode

The Hybris installation comes with startup scripts for Windows and Linux.

Windows

C:\>cd %HYBRIS_HOME%\bin\platform

C:\Apps\hybris\bin\platform> hybrisserver.bat debug

Linux

$ cd ${HYBRIS_HOME}/bin/platform

$ ./hybrisserver.sh debug

Configure Eclipse

  • Launch Eclipse and go to Run -> Debug Configurations

Screen Shot 2017-11-25 at 4.21.21 PM.png
  • Right-click on Remote Java Application and select New

Screen Shot 2017-11-25 at 4.25.14 PM.png
  • Choose a name and select the Hybris code project.  Change localhost to the hostname of the machine running the Hybris app in debug mode.

  • Click the Debug button on the bottom of the dialog screen. This will hook Eclipse with the Hybris server that is running and listening on port 8000.

  • Open the Debug perspective. We can now set breakpoints in our code to begin debugging.

Debugging Exceptions during Hybris Startup

Sometimes we need to debug an exception that occurs during startup.   

In this situation, we need to tell Tomcat to wait for a remote debugger to connect before continuing with its startup routine.

This can be accomplished by modifying bin\platform\tomcat\conf\wrapper-debug.conf and setting suspend=y:

wrapper.java.additional.22=-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y

Troubleshooting

Failed to connect to remote VM. Connection Refused

If you're seeing this error in Eclipse, make sure Tomcat is running in debug mode:

The configuration is under bin\platform\tomcat\conf\wrapper-debug.conf

In this file, there should be entries to tell Tomcat to run in debug mode:

wrapper.java.additional.20=-Xdebug
wrapper.java.additional.21=-Xnoagent
wrapper.java.additional.22=-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n