softwareCobbler / luceedebug

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

Setup in Windows/Tomcat #38

Open ASKemp opened 1 year ago

ASKemp commented 1 year ago

Forgive my ignorance. What's the setup for Windows/Tomcat with regards the setenv file?

Is this an equivalent setenv.bat file for Windows, e.g. C:\lucee\tomcat\bin\setenv.bat ?

If so, what are the corresponding bat file commands as opposed to those for a sh file ?

ChatGPT informs me it's:

set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999" set "JAVA_OPTS=%JAVA_OPTS% -javaagent:C:\abspath\to\luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=C:\abspath\to\luceedebug.jar"

Is this correct?

EDIT: Guess not since I'm running Tomcat as a Windows service and from what I've read this isn't the way to go. Some additional documentation/guidance on setup would be appreciated.

anderslars commented 1 year ago

FWIW I'm running Windows with Tomcat (commandbox) and am using this in my server.json "jvm":{ "args":[ "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:9999", "-javaagent:c:\xxxxxx\luceedebug.jar=jdwpHost=127.0.0.1,jdwpPort=9999,debugHost=localhost,debugPort=10000,jarPath=c:\xxxxxx\luceedebug.jar" ], "javaVersion":"openjdk11_jdk" }

softwareCobbler commented 1 year ago

for windows, it ought to be the path to tomcat's bin, and then a file named setenv.bat

REM this file is c:\foo\bar\whatever\tomcat\bin\setenv.bat
set LDJAR=c:\Users\path\to\luceedebug.jar
set CATALINA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999 -javaagent:%LDJAR%=jdwpHost=localhost,jdwpPort=9999,cfHost=0.0.0.0,cfPort=10000,jarPath=%LDJAR%
ASKemp commented 1 year ago

for windows, it ought to be the path to tomcat's bin, and then a file named setenv.bat

REM this file is c:\foo\bar\whatever\tomcat\bin\setenv.bat
set LDJAR=c:\Users\path\to\luceedebug.jar
set CATALINA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999 -javaagent:%LDJAR%=jdwpHost=localhost,jdwpPort=9999,cfHost=0.0.0.0,cfPort=10000,jarPath=%LDJAR%

I think if you run Tomcat as a Windows service then the setenv.bat file is ignored.

ASKemp commented 1 year ago

Still unable to get this to work. We run a number of Lucee instances under Tomcat as a service on Windows. Tried settings in setenv.bat, catalina.bat, startup.bat, adding to the Java options of the individual instance service control - all without luck,

The instance service control panel seems the best option so far. My existing options are:-

-Dcatalina.home=c:\lucee\tomcat -Dcatalina.base=c:\lucee\tomcat\instances{myInstance} -Dignore.endorsed.dirs=c:\lucee\tomcat\endorsed -Djava.io.tmpdir=c:\lucee\tomcat\instances{myInstance}\temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=c:\lucee\tomcat\instances{myInstance}\conf\logging.properties

Adding to the end... -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:7999

Allows the service to startup and I see port 7999 (trying to use 7999 and 8000 since 9999 is already in use) spring into life using CurrPorts tool as attached to a tomcat9.exe process.

If I then add the second part as... -javaagent:C:\luceedebug\luceedebug\build\libs\luceedebug.jar=jdwpHost=localhost,jdwpPort=7999,cfHost=0.0.0.0,cfPort=8000,jarPath=C:\luceedebug\luceedebug\build\libs\luceedebug.jar

...then the service starts but then stops, so must be something with the format or values of this part. Tried 0.0.0.0, localhost and 127.0.0.1 for cfHost values, same result.

zspitzer commented 1 year ago

If it stops, there must be error logs in the tomcat log directory?

carehart commented 1 year ago

@ASKemp Try changing the path separators in the javaagent arg (both paths, and all the slashes) from \ to either / or \, which is often called for when using Java on Windows.

I'm just offering this as a suggestion, not saying I've confirmed it (as I'm on a phone as I read this). Can you confirm trying it, even if somehow it "doesn't work"? Thx.

carehart commented 3 months ago

@ASKemp how did things finally resolve? Or did they not, for you?