

Attach Remote Debugger to Jar File and Scala REPL
source link: https://www.tuicool.com/articles/hit/fMZ7RrV
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

I was investigating a bug that would only happen in production and wanted to attach a debugger to a particular workflow. I could have run the entire application and attached remotely, via:
java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9998 path/to/my/jar/some.jar
In my case, I wanted to invoke a specific method and see what happens via Scala REPL.
Turns out it’s pretty easy to do, although not easy to find how to do it. I just had to trigger the Scala REPL command with the jar file passed into the -cp parameter. I also had to prepend remote debugger parameters that I got from InteliJ with -J
So the final command looked as follows:
scala -cp path/to/my/jar/some.jar -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9998
I also had to forward the port via ssh to my local machine, as follows:
ssh some-remote-server.com -L 9998:127.0.0.1:9998 -N
IntelliJ config for the remote debugger is under:
+ Remote
Happy coding!
Recommend
-
89
Croissant A Lua REPL and debugger implemented in Lua
-
10
Why can not I start a jar file? advertisements I downloaded a jar file and it was automatically saved to my downloads folder (I am using mac o...
-
10
-
9
Attach to a Remote Process with LLDB in Visual Studio 2022 Preview 3 Erika August 11th, 2021 You can now use At...
-
8
Reading Time: 3 minutes The importance of writing this blog is to solve the following problem(creating executable jar file) which I faced during my project. In this blog, we see a simple scala application i.e “HelloWorld” o...
-
35
Creating a ClassLoader to load a JAR file from a set of bytes advertisements I'm looking to write a custom class loader that will load a
-
10
I’ve been working on a video editor built on top of Electron and Rust, where Rust does the heavy lifting, and Electron (paired with Svelte) takes care of the UI. Debugging the JS is easy enough: pop...
-
11
The 10x debugger for your Java, Kotlin, and Scala...
-
8
Jigang Zhang 张吉刚 June 8, 2022 2 minute read...
-
5
Introduction: I would like to explain about how to Attach File to ODATA . This blog Post is mainly useful for beginners. Please follow the below steps to Create attachments. Step: 1...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK