How to run a remote debug of an Entando K8S container in IntelliJ?

Hey guys, I’m trying to extend some Entando functionalities and I need some debug to figure out what is happening, how can I proceed?

I’m using IntelliJ Idea

Getting inspiration from this

I’ve solved as follows:

  1. Open your deployment definition file, search for the containers env var list and add this:

    • name: _JAVA_OPTIONS
      value: -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n
  2. Restart your deployment (maybe you need to scale down before)

  3. Open a terminal and run oc port-forward [POD_NAME] 8000 setting your desired pod name

  4. Set and run a remote debug configuration like in the attached screenshot

Let’s debug!


Thanks! This worked perfectly for me.

One comment, my settings were slightly different to get this working in my non-OpenShift local quickstart environment.

  1. Set JAVA_OPTS (instead of JAVA_OPTIONS) to the debug settings. This ends up replacing the default settings instead of adding to the existing so an alternative is to check the existing values and add the debug settings to that, e.g. -XX:+UseParallelGC -Xms40m -Xmx256m -XX:+AggressiveOpts -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dorg.apache.tomcat.util.LOW_MEMORY=true...
  2. I had to include the address option on the port-forward so I could access the debug port, e.g. kubectl port-forward --address deploy/quickstart-server-deployment 5005:5005