Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jdb empty screen, how to debug with jdb #91

Open
opensourcegeek opened this issue Nov 24, 2019 · 9 comments
Open

jdb empty screen, how to debug with jdb #91

opensourcegeek opened this issue Nov 24, 2019 · 9 comments

Comments

@opensourcegeek
Copy link

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.

@idanarye
Copy link
Owner

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?

@opensourcegeek
Copy link
Author

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.

@idanarye
Copy link
Owner

  1. It looks like you already set the srcpath correctly, but classpath should be './target/classes.
  2. You need the fully qualified name of the entry point class - com.foo.boo.Application.

@opensourcegeek
Copy link
Author

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 ==

@idanarye
Copy link
Owner

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;?

@opensourcegeek
Copy link
Author

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.

@skriems
Copy link

skriems commented Apr 5, 2020

I have the same issue when attaching 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:

grafik

I'm going to dig a little further later today...

@rgouzal
Copy link

rgouzal commented May 26, 2020

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?

@rgouzal
Copy link

rgouzal commented May 26, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants