reddit / emacs

I figured out how to use dap-mode and debug my enterprise java code and I'm so excited about the productivity boost for future java development!

jigarthanda-paal · 2022-03-13 02:30
/thread All hail doom emacs and lsp-mode maintainers!
jigarthanda-paal · 2022-03-13 03:24
(Wrote a bunch of junit tests, and ran dap-breakpoint-add and dap-java-debug-test-method) enterprise code which doesn't expose a main method easily which makes dap-debug not work
SasukeUchiha231 · 2022-03-13 07:14
You can still attatch the debugger though, so i think it still might work
lrochfort · 2022-03-13 07:47
You don't need a main method. Connect to the debug port on your app server
tonicinhibition · 2022-03-13 08:09
Very nice, I've been hoping to do this for AutoLisp. It would be so nice to use some decent debug tooling in my day job.
alessandrobertulli · 2022-03-13 09:41
Nice! Can you share your config? I'm struggling to make Emacs (LSP) work with Java
jigarthanda-paal · 2022-03-13 13:37
I kept getting a connection refused error regardless of the port I used. How do I fix that? `Warning (emacs): Initialize request failed: Failed to attach to remote debuggee VM. Reason: java.net.ConnectException: Connection refused: (Connection refused)`
jigarthanda-paal · 2022-03-13 13:38
I use Doom Emacs so my config is very bare-bones. The set up works out of the box
yyoncho · 2022-03-13 16:56
did you check if the port is open?
jigarthanda-paal · 2022-03-13 18:23
How do I do that? I don't think it was. Should I open an ssh tunnel on my localhost?
yyoncho · 2022-03-13 19:20
By `open` I meant `taken`. What params do you pass to the server to enable the remote debugging?
jigarthanda-paal · 2022-03-13 19:38
I'm not sure if I'm doing it correctly. this is the java attach template I'm using. ``` (dap-register-debug-template "Java Attach" (list :name "Java Attach" :type "java" :request "attach" :hostName "localhost" :port nil)) ```
yyoncho · 2022-03-13 19:50
first you have to start the application with remote debug args, check this: https://stackoverflow.com/questions/975271/remote-debugging-a-java-application
jigarthanda-paal · 2022-03-13 20:01
interesting - I'll have to look into how to do this on my code base because the application launch is rather abstracted away from me. Thanks /u/yyoncho for your response! Edit: (Scrubbing some pii)