Unable to debug with CodeRunner

Hello,

I’m trying to change an event handler for my app. I’ve followed the steps outlined here: https://backendless.com/docs/bl-java/bl_read_me_first.html
I am able to start CodeRunner with the following output:

milen@Milens-New-MBP HelpAPaw__JAVA_default_coding % ./bin/CodeRunner.sh
Path to “JAVA_HOME”: /Users/milen/Library/Java/JavaVirtualMachines/openjdk-14.0.2/Contents/Home

Running CodeRunner …
env JAVA_HOME=/Users/milen/Library/Java/JavaVirtualMachines/openjdk-14.0.2/Contents/Home /Users/milen/Library/Java/JavaVirtualMachines/openjdk-14.0.2/Contents/Home/bin/java -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -server -Xms384m -Xmx768m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Dlogback.configurationFile=logback.xml --add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.sun.management.jmxremote.port=1097 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=backendless-dev.local -cp “:…/libs/” com.backendless.coderunner.CodeRunnerLoader

08:55:01.394 [INFO] c.b.c.CodeRunnerLoader |main| JDK from “JAVA_HOME” - /Users/milen/Library/Java/JavaVirtualMachines/openjdk-14.0.2/Contents/Home
08:55:01.406 [INFO] c.b.c.CommandLineProcessor |main| CodeRunner™ Backendless Debugging Utility
08:55:01.406 [INFO] c.b.c.CommandLineProcessor |main| Copyright© 2020 Backendless Corp. All rights reserved.
08:55:01.406 [INFO] c.b.c.CommandLineProcessor |main| Build date: 2020-08-21T10:54:23Z
Version: 6.0.10
Build id: 198337
VCS revision: 7c400b026c5a0c79cbb3a2b9b1d33fcac545a413
08:55:01.407 [INFO] c.b.c.CommandLineProcessor |main| CodeRunner session is running for 2 hours and will be terminated on 10:55:01.407435[UTC]

08:55:01.441 [INFO] c.b.h.HealthCheckHttpServer |main| Management port is absent, management server not started
08:55:01.442 [INFO] c.b.coderunner.LocalCodeRunner |main| Registering runner on: ‘https://api.backendless.com
08:55:01.443 [INFO] c.b.coderunner.LocalCodeRunner |main| Application ID: ‘BDCD56B9-351A-E067-FFA4-9EA9CF2F4000’
08:55:01.443 [INFO] c.b.coderunner.LocalCodeRunner |main| Api key: ‘35577C95-0D09-F75B-FF06-2F92E51C9400’
08:55:04.134 [INFO] c.b.coderunner.LocalCodeRunner |main| Runner successfully registered
08:55:04.140 [INFO] c.b.c.parser.EventModelParser |main| Parsing event model…
08:55:04.172 [WARN] c.b.c.parser.EventModelParser |main| Timer’s ‘MoveOldSignals’ start time is in the past. The timer will run accordingly to the schedule.
08:55:04.510 [INFO] c.b.c.d.DebuggerConsoleInterface |main| Build successfully: 3 event handlers and 1 timer and 0 services
08:55:04.511 [INFO] c.b.c.d.DebuggerConsoleInterface |main| Deploying model to server, and starting debug…
08:55:04.932 [INFO] c.b.c.d.DebuggerConsoleInterface |main| Model successfully deployed.
08:55:04.932 [INFO] c.b.c.d.DebuggerConsoleInterface |main| Waiting for events…

This is the screenshot of my remote debugging configuration:

However, when I try to run it I keep getting the following error:

Error running ‘CodeRunner’: Unable to open debugger port (localhost:5005): java.net.ConnectException “Connection refused (Connection refused)”

I’ve tried restarting IntelliJ Idea and the computer. I’ve checked if port 5005 is busy:

milen@Milens-New-MBP ~ % sudo lsof | grep localhost
Password:
idea 752 milen 194u IPv6 0x998c0bc9875bc931 0t0 TCP localhost:6942 (LISTEN)
idea 752 milen 450u IPv6 0x998c0bc9875bcf51 0t0 TCP localhost:63342 (LISTEN)
idea 752 milen 519u IPv6 0x998c0bc9875bb6d1 0t0 TCP localhost:49412 (LISTEN)
idea 752 milen 523u IPv6 0x998c0bc9875bedf1 0t0 TCP localhost:49412->localhost:49419 (ESTABLISHED)
java 820 milen 75u IPv6 0x998c0bc9875bdb91 0t0 TCP localhost:49419->localhost:49412 (ESTABLISHED)

I’ve also tried to change the port to a different number and still get the same error!

This line from the CodeRunner.sh execution is probably a hint to the problem:

08:55:01.441 [INFO] c.b.h.HealthCheckHttpServer |main| Management port is absent, management server not started
However, I have no idea what is causing it and how can I fix it.

Can you provide some assistance in solving this problem, please?

Best,
Milen

Hi, Milen.
Could you post here the entire CodeRunner.sh file.
Or check manually whether CODERUNNER_RUN_CMD contains $DEBUG_CR_ARGS. If no, just add it to get something like:
CODERUNNER_RUN_CMD="env JAVA_HOME=$JAVA_HOME $JAVA_EXEC $JAVA_ARGS $ADD_OPENS_ARGS $JMX_ARGS $DEBUG_CR_ARGS -cp \"*:../libs/*\" com.backendless.coderunner.CodeRunnerLoader"

Hi Oleg,

Here is the file:

#!/bin/bash

cd dirname "$0";

if [[ -z $JAVA_HOME ]]; then
JAVA_HOME=java -XshowSettings:properties -version 2>&1 | grep -E "java\.home" | awk '{print $3}';
fi

echo “Path to “JAVA_HOME”: $JAVA_HOME”

JAVA_EXEC="$JAVA_HOME/bin/java"

Minimal version to run CodeRunner

MINIMAL_VERSION=11

Check if Java is present and the minimal version requirement

java_version=$JAVA_EXEC --version | head -1 | awk '{print substr ($2, 1, 2);}'

if [ $java_version ];
then
if [ $java_version -lt $MINIMAL_VERSION ]; then
echo “Error: Java version is too low to run CodeRunner. At least Java ${MINIMAL_VERSION} needed.”;
fi

else
echo “Not able to find Java executable or version. Please check your Java installation.”;

exit 1;
fi

DEBUG_CR_ARGS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"

JMX_ARGS="
-Dcom.sun.management.jmxremote.port=1097
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=backendless-dev.local"

JAVA_ARGS="
-XX:-OmitStackTraceInFastThrow
-XX:+HeapDumpOnOutOfMemoryError
-server
-Xms384m
-Xmx768m
-Duser.timezone=UTC
-Dfile.encoding=UTF-8
-Djava.net.preferIPv4Stack=true
-Dlogback.configurationFile=logback.xml
${JAVA_ARGS}"

ADD_OPENS_ARGS="
–add-modules java.se
–add-exports java.base/jdk.internal.ref=ALL-UNNAMED
–add-opens java.base/java.lang=ALL-UNNAMED
–add-opens java.base/java.nio=ALL-UNNAMED
–add-opens java.base/sun.nio.ch=ALL-UNNAMED
–add-opens java.management/sun.management=ALL-UNNAMED
–add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED"

CODERUNNER_RUN_CMD=“env JAVA_HOME=$JAVA_HOME $JAVA_EXEC $JAVA_ARGS $ADD_OPENS_ARGS $JMX_ARGS -cp “:…/libs/” com.backendless.coderunner.CodeRunnerLoader”

if [[ “$1” == “nohup” ]];
then
shift
CODERUNNER_RUN_CMD=“nohup ${CODERUNNER_RUN_CMD} $@ &”
else
CODERUNNER_RUN_CMD="${CODERUNNER_RUN_CMD} $@"
fi

separator="----------------------------------------"
echo -e “${separator}\nRunning CodeRunner …”
echo $CODERUNNER_RUN_CMD
echo -e “${separator}\n”
eval $CODERUNNER_RUN_CMD

From what I see DEBUG_CR_ARGS is only defined but not used.

Yes, this is the problem. I’ve added to the previous post how it should look like.
We will fixed it. Thanks!

Now it works. Thanks!