Extension Debugger crashes Lucee 6 when dumping a variable

Requirements:

  • Lucee 6.2 (latest, but all versions should be affected)
  • Extension Debugger 3.0.0.4 (formerly luceedebug)

Steps to reproduce:

  • Start debugging
  • In the “VARIABLES” panel find a variable with an array or struct value
  • Right click and select “dump” OR “dump as JSON”
  • Lucee crashes!

This error is logged:

[ERROR] java.lang.NoSuchMethodError: 'jakarta.servlet.ServletConfig lucee.runtime.PageContext.getServletConfig()'
[ERROR]         at org.lucee.extension.debugger.coreinject.DebugManager$PageContextAndOutputStream.ephemeralPageContextFromOther(DebugManager.java:202)
[ERROR]         at org.lucee.extension.debugger.coreinject.DebugManager.lambda$doDumpAsJSON$0(DebugManager.java:287)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:1583)

Why is an there an exception?

The method ephemeralPageContextFromOther cannot call getServletConfig, as it returns javax.servlet.ServletConfig instead of jakarta.servlet.ServletConfig.

This error is caught, and it should dump an error message instead.

Why does Lucee crash?

The methods doDump() and doDumpAsJSON both call ephemeralPageContextFromOther and catch any errors.

If an error is caught they call System.exit(1) and Lucee crashes.

This is not a graceful exit at all:

  • When testing with commandbox, I have to use ctrl+c, then again when it hangs on “Stopping server…”.
  • The VS Code extension doesn’t disconnect the debugger for a while
  • I cannot restart the server until I’ve killed the java process that is still using the debug port.

While investigating the exception I removed the calls to System.exit(1), which prevented the crash and these error messages were dumped instead:

  • “if this text is present, something went wrong when calling writeDump(…)”
  • “Something went wrong when calling serializeJSON(…)”

Workaround - custom build

I was able to build a working agent jar file like this:

cd agent
mvn clean package -Dlucee.version=6.2.6.19

This doesn’t help my docker image, which is currently fetching the agent from https://repo1.maven.org/maven2/org/lucee/debugger-agent/3.0.0.4/debugger-agent-3.0.0.4.jar

Potential fix

It seems like a lot of other places in the code use reflection to handle issues with javax/jakarta. I count 85 calls to getMethod() and 3 to getMethods().

I was able to code a fix with some AI help.