Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger does not attach (using Docker/Commandbox Image) #66

Closed
BrentGrammer opened this issue Sep 21, 2024 · 2 comments
Closed

Debugger does not attach (using Docker/Commandbox Image) #66

BrentGrammer opened this issue Sep 21, 2024 · 2 comments

Comments

@BrentGrammer
Copy link

BrentGrammer commented Sep 21, 2024

I have a docker container using a commandbox image tagged with jdk11, and I can see luceedebug start up, but when I set a breakpoint and press the debug button to attach in VS Code, the stepper menu panel appears for a second and disappears. The debugger does not attach and none of the breakpoints set work or catch. I cannot find any error output or logs and am not sure how to debug it or figure out why it's not working.

A repo with the code I am running can be found here: https://github.com/BrentGrammer/ModernizeJSApp/tree/Luceedebug

OS: Windows 10
luceedebug VSCode extension version: v2.0.10
.jar path on my machine (in my project folder): ./luceedebug-2.0.14.jar

here is my launch.json

 "version": "0.2.0",
  "configurations": [
    {
      "type": "cfml",
      "request": "attach",
      "name": "luceedebug",
      "hostName": "localhost",
      "port": 10000,
      "pathTransforms": [
        {
          "idePrefix": "${workspaceFolder}",
          "serverPrefix": "/app"
        }
      ],
    }

Here is my docker compose yml:

services:
  server:
    image: "ortussolutions/commandbox:jdk11"
    container_name: luceeServer
    environment:
      - cfconfig_adminPassword=admin
      - BOX_SERVER_PROFILE=development
      - BOX_JAVA_ARGS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:9999 -javaagent:/opt/luceedebug/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/opt/luceedebug/luceedebug.jar
    ports:
      - 8080:8080
      - 9999:9999
      - 10000:10000
    volumes:
      - ./:/app
      - ./luceedebug-2.0.14.jar:/opt/luceedebug/luceedebug.jar
    depends_on:
      - db

When running docker compose up I get the following output:

luceeServer              | [INFO] 2024-09-21T15:19:48Z - Server Home Directory set to: /usr/local/lib/serverHome
luceeServer              | [INFO] 2024-09-21T15:19:48Z - Generating server startup script
luceeServer              | Picked up JAVA_TOOL_OPTIONS: -Djava.util.logging.config.file=/usr/local/lib/build/resources/text.logging.properties 
modernizelegacyapp-db-1  | 2024-09-21T15:19:48.585414Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
luceeServer              | [luceedebug] Method 'udfCall1' in class 'system/services/serverservice_cfc$cf' became too large after instrumentation (size=74005). luceedebug won't be able to hit breakpoints in, or expose frame information for, this file.
luceeServer              | [INFO] 2024-09-21T15:19:59Z - Listening for transport dt_socket at address: 9999
luceeServer              | [luceedebug] version 2.0.14
luceeServer              | [luceedebug] agent premain complete
luceeServer              | [luceedebug] Loaded luceedebug.coreinject.DebugManager@ff684e1 with ClassLoader 'lucee.core [41]'
luceeServer              | [luceedebug] attempting jdwp self connect to jdwp on localhost:9999...
luceeServer              | [luceedebug] jdwp self connect OK
luceeServer              |  √ | Starting Server
luceeServer              |    |------------------------------
luceeServer              |    | Looking for server JSON file by convention: /app//server.json
luceeServer              |    | webroot pulled from server's JSON: /app/wwwroot/
luceeServer              |    | Site name - wwwroot
luceeServer              |    | Webroot - /app/wwwroot/
luceeServer              |    | Site config file - /app//server.json
luceeServer              |    | Building a WAR from local jars.
luceeServer              |    | Start script for shell [bash] generated at: /app/server-start.sh
luceeServer              |    | Server start command:
luceeServer              |    |     /opt/java/openjdk/bin/java
luceeServer              |    |     -cp /usr/local/lib/CommandBox/lib/runwar-5.0.0.jar runwar.Start /
luceeServer              |    | usr/local/lib/serverHome/serverInfo.jso
luceeServer              |    | Dry run specified, exiting without starting server.
luceeServer              |    |------------------------------
luceeServer              |    | √ | Overriding server.json values from env vars
luceeServer              |    |   |----------------------------------------------------------
luceeServer              |    |   | Overridding [PROFILE] with OS environment variable [BOX_SERVER_PROFIL
luceeServer              |    |   | E
luceeServer              |    |   | Overridding [APP.SERVERHOMEDIRECTORY] with OS environment variable [B
luceeServer              |    |   | OX_SERVER_APP_SERVERHOMEDIRECTORY
luceeServer              |    |   |----------------------------------------------------------
luceeServer              |    | √ | Setting site [wwwroot] Profile to [development]
luceeServer              |    |   |--------------------------------------------------------------
luceeServer              |    |   | Profile set from profile property in server.json
luceeServer              |    |   | Block CF Admin disabled
luceeServer              |    |   | Block Sensitive Paths disabled
luceeServer              |    |   | Block Flash Remoting enabled
luceeServer              |    |   | Directory Browsing enabled
luceeServer              |    |   | File Caching disabled
luceeServer              |    |   |--------------------------------------------------------------
luceeServer              |    | √ | Loading CFConfig into server
luceeServer              |    |   |-------------------------------------------
luceeServer              |    |   | Found OS environment variable [cfconfig_adminPassword]
luceeServer              |    |   | Importing into [luceeserver]...
luceeServer              |    |   | [adminPassword] set.
luceeServer              |    |   | No Web context admin password found. Setting your admin password to t
luceeServer              |    |   | he same as your Server context password
luceeServer              |    |   | [adminPassword] set.
luceeServer              |    |   |-------------------------------------------
luceeServer              | [INFO] 2024-09-21T15:19:59Z - Starting server using generated script: /usr/local/bin/startup.sh
luceeServer              | NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.cs=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.annotation=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.module=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.net.spi=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.channels=ALL-UNNAMED --add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.nio.charset.spi=ALL-UNNAMED --add-opens=java.base/java.nio.file=ALL-UNNAMED --add-opens=java.base/java.nio.file.attribute=ALL-UNNAMED --add-opens=java.base/java.nio.file.spi=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.security.interfaces=ALL-UNNAMED --add-opens=java.base/java.security.spec=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.text.spi=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED 
--add-opens=java.base/java.time.chrono=ALL-UNNAMED --add-opens=java.base/java.time.format=ALL-UNNAMED --add-opens=java.base/java.time.temporal=ALL-UNNAMED --add-opens=java.base/java.time.zone=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/java.util.function=ALL-UNNAMED --add-opens=java.base/java.util.jar=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.util.spi=ALL-UNNAMED --add-opens=java.base/java.util.stream=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/javax.crypto=ALL-UNNAMED --add-opens=java.base/javax.crypto.interfaces=ALL-UNNAMED --add-opens=java.base/javax.crypto.spec=ALL-UNNAMED --add-opens=java.base/javax.net=ALL-UNNAMED --add-opens=java.base/javax.net.ssl=ALL-UNNAMED --add-opens=java.base/javax.security.auth=ALL-UNNAMED --add-opens=java.base/javax.security.auth.callback=ALL-UNNAMED --add-opens=java.base/javax.security.auth.login=ALL-UNNAMED --add-opens=java.base/javax.security.auth.spi=ALL-UNNAMED --add-opens=java.base/javax.security.auth.x500=ALL-UNNAMED --add-opens=java.base/javax.security.cert=ALL-UNNAMED --add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-opens=java.desktop/com.sun.java.swing.plaf.motif=ALL-UNNAMED --add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.nimbus=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-opens=java.base/sun.security.rsa=ALL-UNNAMED --add-opens=java.base/sun.security.pkcs=ALL-UNNAMED --add-opens=java.base/sun.security.x509=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED --add-opens=java.base/sun.util.cldr=ALL-UNNAMED --add-opens=java.base/sun.util=ALL-UNNAMED --add-opens=java.base/sun.util.locale.provider=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED  --add-exports=java.desktop/sun.java2d=ALL-UNNAMED --add-exports=java.base/sun.util=ALL-UNNAMED    
luceeServer              | Picked up JAVA_TOOL_OPTIONS: -Djava.util.logging.config.file=/usr/local/lib/build/resources/text.logging.properties
luceeServer              | WARNING: package com.sun.java.swing.plaf.windows not in java.desktop
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server - ******************************************************************************
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server - Starting Runwar
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server -   - Runwar Version: 5.0.0
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server -   - Java Version: 11.0.24+8 (Eclipse Adoptium)
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server -   - Java Home: /opt/java/openjdk
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server - ******************************************************************************
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server - Listeners:
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server -   - Binding HTTP on 0.0.0.0:8080
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server - ******************************************************************************
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server - Configuring Servlet
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server -   Found WEB-INF: '/usr/local/lib/serverHome/WEB-INF'
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server - ******************************************************************************
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server - Creating deployment [default]
luceeServer              | [INFO] 2024-09-21T15:20:00Z runwar.server -     Web Root: /app/wwwroot
luceeServer              | WARNING: An illegal reflective access operation has occurred
luceeServer              | WARNING: Illegal reflective access by lucee.commons.lang.ClassUtil (jar:/usr/local/lib/serverHome/WEB-INF/lucee-server/patches/5.4.4.38.lco) to constructor com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl()
luceeServer              | WARNING: Please consider reporting this to the maintainers of lucee.commons.lang.ClassUtil
luceeServer              | WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
luceeServer              | WARNING: All illegal access operations will be denied in a future release
luceeServer              | [INFO] 2024-09-21T15:20:03Z runwar.server - ******************************************************************************
luceeServer              | [INFO] 2024-09-21T15:20:03Z runwar.server - Starting 'stop' listener thread - Host: 127.0.0.1 - Socket: 43055
luceeServer              | [INFO] 2024-09-21T15:20:03Z runwar.server - Server is up - stop-port:43055 PID:8 version 5.0.0
@softwareCobbler
Copy link
Owner

Cool, thanks for the repro, that helped out a lot.

Small tweak to your config will make this work, it seems that you are having the debugger run on some kind of ephemeral-for-setup-purposes JVM that then kicks off the JVM you actually want to debug.

Basically, move jvm args from your docker ENV into to the server.json "jvm" section

diff --git a/compose.yaml b/compose.yaml
index c6f50e4..5fb776f 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -5,7 +5,6 @@ services:
     environment:
       - cfconfig_adminPassword=admin # set the admin page password
       - BOX_SERVER_PROFILE=development # needed to start in development and enable admin
-      - BOX_JAVA_ARGS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:9999 -javaagent:/opt/luceedebug/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/opt/luceedebug/luceedebug.jar
     ports:
       - 8080:8080
       - 9999:9999
diff --git a/server.json b/server.json
index 7127985..7b890f4 100644
--- a/server.json
+++ b/server.json
@@ -4,5 +4,12 @@
       "blockCFAdmin": false,
       "blockSensitivePaths": false,
       "webroot": "/app/wwwroot"
+    },
+    "jvm":{
+      "args":[
+          "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999",
+          "-javaagent:/opt/luceedebug/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/opt/luceedebug/luceedebug.jar"
+      ],
+      "javaVersion":"openjdk11_jdk"
     }
 }

Thanks to @jamiejackson for his investigation in #32 (especially for that magic _jdk suffix for the java version).

image

@BrentGrammer
Copy link
Author

@softwareCobbler Thank you! That works with your changes. I have no idea how an "ephemeral-for-setup-purposes JVM" got started and did not intentionally set that up anywhere (maybe some kind of under the hood stuff going on in the docker image?). In any case, thank you for your work on this - I can't live without being able to step through codebases in Lucee..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants