vim-vebugger
vim-vebugger copied to clipboard
jdb empty screen, how to debug with jdb
I'm trying to run vebugger for java but I'm seeing an empty window whenever I kick off jdb. It seems to not start the app and it just shows empty window for a while. I'm running a spring boot app, it's a maven project and following is the command I'm using
:call vebugger#jdb#start('Application', { 'classpath': './target', 'srcpath': './src' })
I've tried several variations of it by giving absolute path for classpath and srcpath variables etc. Nothing seems to make any difference. Any pointers would be greatly helpful, as my vim setup is really good at the moment missing just the debugging experience even for writing Java code. Thanks.
Try running :VBGtoggleTerminalBuffer
- preferably right after you start the debugger:
:call vebugger#jdb#start('Application', { 'classpath': './target', 'srcpath': './src' }) | VBGtoggleTerminalBuffer
What gets written there? Any errors?
Yea I'm seeing following error,
stop on Application.main run Application 0 monitor where Initializing jdb ...
Deferring breakpoint Application.main. It will be set after the class is loaded. run Application 0 Set uncaught java.lang.Throwable Set deferred uncaught java.lang.Throwable
VM Started: Error: Could not find or load main class Application The application exited == DEBUGGER TERMINATED ==
It looks like it cannot find main class. I've the Application class inside ./target/classes/com/foo/boo/Application and srcpath is ./src. How should I set those variables? By the way having a single java file, compiling it and starting vebugger works. I still haven't figured out how to evaluate variables to see their values but it actually stops at the break point correctly which is great.
- It looks like you already set the
srcpath
correctly, butclasspath
should be'./target/classes
. - You need the fully qualified name of the entry point class -
com.foo.boo.Application
.
Thanks @idanarye - I still get the error
:call vebugger#jdb#start('com.foo.boo.Application', { 'classpath': './target/classes', 'srcpath': './src' } ) | VBGtoggleTerminalBuffer
stop on com.foo.boo.Application.main run com.foo.boo.Application 0 monitor where Initializing jdb ...
Deferring breakpoint com.foo.boo.Application.main. It will be set after the class is loaded. run com.foo.boo.Application 0 Set uncaught java.lang.Throwable Set deferred uncaught java.lang.Throwable
VM Started: Error: Could not find or load main class com.foo.boo.Application The application exited == DEBUGGER TERMINATED ==
Is ./target/classes/com/foo/boo/Application.class
really your compiled .class
object, or was that just an example? Does your Application.java
start with package com.foo.boo;
?
It is definitely there, but what I don't know is if there's any Spring boot glue code involved that makes it look like it's not got main method. Thanks for your help.
I have the same issue when attach
ing to a docker container with a maven multi-module project. I invoke vebugger with:
: call vebugger#jdb#attach('8000', {'classpath': '<submodule>/target/classes', 'srcpath': '<submodule>/src'})
In the vebugger's terminal, there's no error message reported but the buffer with the code gets emptied and I see a warning, that the Class is not on the classpath:

I'm going to dig a little further later today...
I tried to run the vim-vebugger and launch it on a spring maven project and I got some errors, at first I was getting the error that @opensourcegeek was getting:
Could not find or load main class: MyApplication
After doing what @idanarye suggested the first error disappeared and I got another error:
Exception occurred: java.lang.ClassNotFoundException (uncaught)"thread=main", java.lang.ClassLoader.loadClass(), line=431 bci=121
[1] java.lang.ClassLoader.loadClass (ClassLoader.java:431)
[2] sun.misc.Launcher$AppClassLoader.loadClass (Launcher.java:352)
[3] java.lang.ClassLoader.loadClass (ClassLoader.java:352)
[4] com.zyzt.testapplication.MyApplication.main (MyApplication.java:22)
It's crashing on this line:
SpringApplication.run(MyApplication.class, args);
Could it be crashing because of not finding classpath for SpringApplication?
I tried to run the vim-vebugger and launch it on a spring maven project and I got some errors, at first I was getting the error that @opensourcegeek was getting:
Could not find or load main class: MyApplication
After doing what @idanarye suggested the first error disappeared and I got another error:
Exception occurred: java.lang.ClassNotFoundException (uncaught)"thread=main", java.lang.ClassLoader.loadClass(), line=431 bci=121 [1] java.lang.ClassLoader.loadClass (ClassLoader.java:431) [2] sun.misc.Launcher$AppClassLoader.loadClass (Launcher.java:352) [3] java.lang.ClassLoader.loadClass (ClassLoader.java:352) [4] com.zyzt.testapplication.MyApplication.main (MyApplication.java:22)
It's crashing on this line:
SpringApplication.run(MyApplication.class, args);
Could it be crashing because of not finding classpath for SpringApplication?
Note: I have this in my .bashrc to use lombok:
export JAVA_TOOL_OPTIONS=-javaagent:/home/khalid/.m2/repository/org/projectlombok/lombok/1.18.12/lombok-1.18.12.jar -Xbootclasspath/a:/home/khalid/.m2/repository/org/projectlombok/lombok/1.18.12/lombok-1.18.12.jarjavaagent:/home/khalid/.m2/repository/org/projectlombok/lombok/1.18.12/lombok-1.18.12.jar -Xbootclasspath/a:/home/khalid/.m2/repository/org/projectlombok/lombok/1.18.12/lombok-1.18.12.jar