softwareCobbler / luceedebug

line debugger for lucee
GNU Lesser General Public License v2.1
44 stars 15 forks source link

Usage with CommandBox #32

Open jamiejackson opened 1 year ago

jamiejackson commented 1 year ago

I thought I'd look into the path translation problem on Windows but I fell into a bunch of rabbit holes.

I've been toying with the idea of having a working commandbox and/or docker example that people could try so I tried spinning things up in commandbox, but first, there was a learning curve to commandbox, and finally and I wasn't able to run it.

Any ideas?

{
    "name":"lucee@5.3.10.97",
    "jvm":{
        "args":[
            "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999",
            "-javaagent:C:/Users/jamie/projects/luceedebug/luceedebug/build/libs/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=C:/Users/jamie/projects/luceedebug/luceedebug/build/libs/luceedebug.jar"
        ],
        "javaVersion":"openjdk11"
    },
    "app":{
        "cfengine":"lucee@5.3.10.97"
    }
}

server run gave the following:

[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Starting RunWAR 4.7.16
[INFO ] Runwar: Binding HTTP on 127.0.0.1:23481
[INFO ] Runwar: Enabling HTTP/2
[INFO ] Runwar: Starting background lucee@5.3.10.97 [lucee 5.3.10+97] from: /C:/Users/jamie/.CommandBox/lib/runwar-4.7.16.jar
[INFO ] Starting in background -
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Starting RunWAR 4.7.16
[INFO ] Runwar: Binding HTTP on 127.0.0.1:23481
[INFO ] Runwar: Enabling HTTP/2
[INFO ] Runwar: Servlet Context: /
[INFO ] Runwar: Log Directory: C:\Users\jamie\.CommandBox\server\7D0C5A764415367927375B99EF8F97D1-lucee@5.3.10.97\lucee-5.3.10.97\logs
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Parsing 'C:\Users\jamie\.CommandBox\server\7D0C5A764415367927375B99EF8F97D1-lucee@5.3.10.97\lucee-5.3.10.97\WEB-INF\web.xml'
[INFO ] Runwar: Creating deployment [default] in C:\Users\jamie\projects\luceedebug\sample
CommandBox:sample> server log
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Starting RunWAR 4.7.16
[INFO ] Runwar: Binding HTTP on 127.0.0.1:23481
[INFO ] Runwar: Enabling HTTP/2
[INFO ] Runwar: Starting background lucee@5.3.10.97 [lucee 5.3.10+97] from: /C:/Users/jamie/.CommandBox/lib/runwar-4.7.16.jar
[INFO ] Starting in background -
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Starting RunWAR 4.7.16
[INFO ] Runwar: Binding HTTP on 127.0.0.1:23481
[INFO ] Runwar: Enabling HTTP/2
[INFO ] Runwar: Servlet Context: /
[INFO ] Runwar: Log Directory: C:\Users\jamie\.CommandBox\server\7D0C5A764415367927375B99EF8F97D1-lucee@5.3.10.97\lucee-5.3.10.97\logs
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Parsing 'C:\Users\jamie\.CommandBox\server\7D0C5A764415367927375B99EF8F97D1-lucee@5.3.10.97\lucee-5.3.10.97\WEB-INF\web.xml'
[INFO ] Runwar: Creating deployment [default] in C:\Users\jamie\projects\luceedebug\sample
[INFO ] [luceedebug] Loaded luceedebug.coreinject.DebugManager@7ed9499e with ClassLoader 'lucee.core [49]'
[INFO ] [luceedebug] instrumented PageContextImpl <clinit> called spawnWorker...
[INFO ] [luceedebug] attempting jdwp self connect to jdwp on localhost:9999...
[ERROR] java.lang.NoClassDefFoundError: com/sun/jdi/Bootstrap
[ERROR]         at luceedebug.coreinject.DebugManager.getConnector(DebugManager.java:76)
[ERROR]         at luceedebug.coreinject.DebugManager.jdwpSelfConnect(DebugManager.java:89)
[ERROR]         at luceedebug.coreinject.DebugManager.spawnWorker(DebugManager.java:62)
[ERROR]         at luceedebug.LuceeTransformer.transform(LuceeTransformer.java:108)
[ERROR]         at java.instrument/java.lang.instrument.ClassFileTransformer.transform(Unknown Source)
[ERROR]         at java.instrument/sun.instrument.TransformerManager.transform(Unknown Source)
[ERROR]         at java.instrument/sun.instrument.InstrumentationImpl.transform(Unknown Source)
[ERROR]         at java.base/java.lang.ClassLoader.defineClass1(Native Method)
[ERROR]         at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
[ERROR]         at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.defineClass(BundleWiringImpl.java:2312)
[ERROR]         at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.defineClassParallel(BundleWiringImpl.java:2130)
[ERROR]         at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2064)
[ERROR]         at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1533)
[ERROR]         at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:78)
[ERROR]         at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1950)
[ERROR]         at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
[ERROR]         at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
[ERROR]         at java.base/java.lang.Class.privateGetDeclaredMethods(Unknown Source)
[ERROR]         at java.base/java.lang.Class.getMethodsRecursive(Unknown Source)
[ERROR]         at java.base/java.lang.Class.getMethod0(Unknown Source)
[ERROR]         at java.base/java.lang.Class.getMethod(Unknown Source)
[ERROR]         at lucee.loader.engine.CFMLEngineFactory.getEngine(CFMLEngineFactory.java:1468)
[ERROR]         at lucee.loader.engine.CFMLEngineFactory.initEngine(CFMLEngineFactory.java:384)
[ERROR]         at lucee.loader.engine.CFMLEngineFactory.initEngineIfNecessary(CFMLEngineFactory.java:262)
[ERROR]         at lucee.loader.engine.CFMLEngineFactory.getInstance(CFMLEngineFactory.java:168)
[ERROR]         at lucee.loader.engine.CFMLEngineFactory.getInstance(CFMLEngineFactory.java:202)
[ERROR]         at lucee.loader.servlet.LuceeServlet.init(LuceeServlet.java:42)
[ERROR]         at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
[ERROR]         at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:309)
[ERROR]         at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)
[ERROR]         at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:588)
[ERROR]         at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:559)
[ERROR]         at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
[ERROR]         at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
[ERROR]         at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
[ERROR]         at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:601)
[ERROR]         at runwar.Server.createServletDeployment(Server.java:1360)
[ERROR]         at runwar.Server.startServer(Server.java:527)
[ERROR]         at runwar.Start.main(Start.java:51)
[ERROR] Caused by: java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap not found by lucee.core [49]
[ERROR]         at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1565)
[ERROR]         at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:78)
[ERROR]         at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1950)
[ERROR]         at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
[ERROR]         ... 39 more
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: *** stopping server 'lucee@5.3.10.97' (socket 23482)
[INFO ] Runwar: ******************************************************************************
jamiejackson commented 1 year ago

Solved. It was another CommandBox learning opportunity. :-/

Turns out javaVersion defaults to a JRE, unless you explicitly append _jdk.

{
    "name":"lucee@5.3.10.97",
    "jvm":{
        "args":[
            "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999",
            "-javaagent:C:/Users/jamie/projects/luceedebug/luceedebug/build/libs/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=C:/Users/jamie/projects/luceedebug/luceedebug/build/libs/luceedebug.jar"
        ],
        "javaVersion":"openjdk11_jdk"
    },
    "app":{
        "cfengine":"lucee@5.3.10.97"
    }
}
jamiejackson commented 1 year ago

I posted more information here: https://github.com/softwareCobbler/luceedebug/issues/23#issuecomment-1368117021

My takeaway is that it could be good idea to have a CommandBox and/or docker example since I didn't find it straightforward.

I can work on that if you're game.

carehart commented 1 year ago

Did anything ever come of this, @jamiejackson? I'd think a large percent of the luceedebug audience would ALWAYS welcome any more info on using it with Commandbox. :-)

psarin commented 6 months ago

With CommandBox 6 (Mac/Docker), I had to:

  1. Modify Docker files to manually install openjdk11 as using the above "javaVersion": "openjdk11_jdk" server.json option didn't work.
    • Apparently, Ortus uses Adoptium API for d/l java and Adoptium has archived openjdk11_jdk for ARM. CommandBox can't find it.
    • Code I added to my Dockerfile:
      
      # Following command since update-alternatives for openjdk-11 install uses this directory
      RUN mkdir -p /usr/share/man/man1

Add ca-certificates-java to prevent a no certs found error for install of openjdk-11

RUN apt-get update -y && \ apt-get install -y openjdk-11-jdk ca-certificates-java && \ rm -rf /var/lib/apt/lists/*


2. Then, for server.json:

"jvm":{ "heapSize":512, "minHeapSize":256, "javaHome":"/usr/lib/jvm/java-11-openjdk-arm64", "args":[ "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999", "-javaagent:/app/debug/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/app/debug/luceedebug.jar" ] }



3. Celebration!

Hope this helps someone! Thank you for developing luceedebug - I think it will be quite helpful to our team! Let us know how we can contribute to your efforts.