cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Java Cap remote debugging not working with Java 17

nuramon9999
Explorer
0 Likes
4,471

Hello dear community,

Since our setup of our Java CAP application, we have ben able to remotely connect to our deployed application on the provider account following this and similar guides, like debugging instructions for SapMachine. Since we upgraded our Java version to Java 17, we have not been able to connect to our deployed application even with different variants in our manifest.yml.

This is our current manifest.yml (commented out are other attempts that did not resolve the issue):

Following the instructions in the SapMachine guide, in Step 2 we also had an error which we could not really identify and thus had to stop the process:
cf ssh javacap -c "export JAVA_PID=`ps -C java -o pid=` && app/META-INF/.sap_java_buildpack/sap_machine_jre/bin/jcmd $JAVA_PID VM.start_java_debugging"

-> /bin/bash: line 0: export: `2064': not a valid identifier


This is what our mta.yaml for the application we deploy looks like:

The observed behaviour is the following:

-> SSH is enabled

-> Connection through commandline is successful and behaves like we are used to:

> When we try to start the debugger and connect to the application through VS-Code the connection is being refused and the connection breaks:

additional info: here is our launch config to attach to the running ssh-connection:

This exact setup worked with our Java11 application and then somehow stopped working.

If there is any other information I can supply, please inform me.

Thank you in advance,

Pascal.

Accepted Solutions (1)

Accepted Solutions (1)

nuramon9999
Explorer
0 Likes

Hello, I am coming back to add our solution, sorry for being late.

The comments helped a lot, we had to find out the process ID and then it actually works:

pid=$(cf ssh appName -c "ps -C java -o pid=") && cf ssh appName -c "~/app/META-INF/.sap_java_buildpack/sap_machine_jdk/bin/jcmd $pid VM.start_java_debugging" && cf ssh appName -N -T -L 8000:127.0.0.1:8000

Thank you for all of your help.

enryuu
Explorer
0 Likes
Hello, i was able to start remote debug, however when disconnecting from vsCode the remote debug connection remain active. VM.stop_java_debugging does not seem to be a valid command. How can the debug be stopped without restarting the application? Kind regards, Stephan
nuramon9999
Explorer
0 Likes

Hi,
Maybe it is an issue with the commandline-configuration you are using - I use VsCode integrated terminal too and the connection closes, when I Crtl-C or close the terminal instance.
If your issue is security you could turn off ssh of your application and then restart it.


Pascal.

Answers (1)

Answers (1)

0 Likes

Hi,

there should be no change regarding debugging in SapMachine 17. From what I see the problem stems from the "export JAVA_PID=`ps -C java -o pid=`" command. Can you check if just

cf ssh javacap -c "ps -C java -o pid="

returns more than one entry?

Best regards,

Ralf

nuramon9999
Explorer
0 Likes

Hello Ralf,

When I run the command 'cf ssh javacap -c "ps -C java -o pid="', the response is ' 8 ' including a big spacing offset in front of the 8.
Thank you for your answer,

Pascal.

nuramon9999
Explorer
0 Likes

Hello Ralf,

We still have not found a solution for the issue, is there any more feedback you can provide?

Best of wishes,

Pascal Ehrlich

christoffer_fuss
Participant

Hi Pascal,

we have no problems with remote debugging with SapMachine 17. This is our config
mta.yaml

launch.json


Then I use those 2 commands:

cf ssh datatraincap-srv -c "export JAVA_PID=`ps -C java -o pid=` && app/META-INF/.sap_java_buildpack/sap_machine_jre/bin/jcmd $JAVA_PID VM.start_java_debugging"

and then:
cf ssh datatraincap-srv -N -T -L 8000:localhost:8000

If you are working on windows you have to use a normal terminal and no powershell.


This worked on java 11, 14 und 17.

Hope this helps,

Best regards,

Chris

Hi,

since it seems the output of ps on your system causes the problem, you should split up the command. First call

cf ssh javacap -c "ps -C java -o pid="

to get the pid of the java process and then

cf ssh javacap -c "app/META-INF/.sap_java_buildpack/sap_machine_jre/bin/jcmd <pid> VM.start_java_debugging"

with <pid> being the pid of the java process. This should work.

Best regards,

Ralf