I can't debug using breakpoints - java

I'm getting a strange error message in SpringSource Tool Suite (eclipse) when I try to place breakpoints and debug my project, so in this case, when I start Tomcat for debug it shows me the following error message:
"Unable to install breakpoint in bus.GenBUS$$EnhancerByCGLIB$$749137d3 due to missing line number attributes. Modify compiler options to generate line number attributes.
Reason : Absent Line Number Information"
But I have already controlled and everything is fine in Preferences -> Java -> Compiler section (add line number attr... is checked). My project is Spring MVC project... Any suggestions ?

Ignore that. Even if you get that message, the breakpoint is still triggered. This class is temporal, generated by CGLIB. But it still invokes your class, which has the breakpoint.

Related

How to avoid "Sharing is only supported for boot loader classes because bootstrap classpath has been appended" warning during debug with Java 11?

Recently I switched to the Java 11 and start to debug my app and saw this message:
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot
loader classes because bootstrap classpath has been appended
Found only this commit and ticket, but it doesn't tell me much.
Do I need to worry about it?
I had this issue too after installing jdk-12.0.1_windows-x64_bin.zip when trying to use the debugger with IntelliJ IDEA. I was getting an error of (Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended). I found, too, going into Setting and search for async and unchecking the Instrumenting agent box. Worked for me!
You can ignore this warning. It just means that class data sharing is disabled for classes not loaded by the bootstrap class loader.
From Improve Launch Times […] With Application Class-Data Sharing:
The JVM loads some of the JDK classes with the bootstrap class loader
and the rest with the system class loader, but includes all of them in
its default archive. When IntelliJ executes your project, it tells the
JVM to load some code with the bootstrap class loader by appending to
that class path (second part of the message). Now, that means that the
portion of the archive that contains classes loaded by the system
class loader is potentially invalidated and so the JVM partially
deactivates sharing (first part of the message).
You could disable class data sharing completely with -Xshare:off, but you would lose some performance.
I had this issue after installing Java12 when trying to use the debugger with Intellij Idea. The solution that I found was to go into Setting and searching for async and unchecking the Instrumenting agent box.
For me, the issue occurred only when I ran in Docker, and when I used a java command line agent like the DataDog APM agent (-javaagent:/dd-java-agent.jar).
When I ran in my JDK11 runtime environment (without the agent) I did not get the warnings.
For Intellij IDE -> Settings/Preferences dialog ( Ctrl+Alt+S ), go to Build | Execution | Deployment | Debugger | Async -> uncheck instrumenting agent
1.Open the Preferences option;
2.Find the Build,Execution,Deployment option;
3.Enter the Debugger --> Async Stack Traces ;
4.Uncheck the Instrumenting agent(requires debugger restart) ;
Please see this for detailed information.
Given this warning in IntelliJ is harmless (see https://stackoverflow.com/a/57957031/779173) you could just hide the line from your Console view by right-clicking on the line and selecting "Fold Lines Like This"
Having done this, you'll just see:
"C:\Program Files\Java\jdk-17.0.2\bin\java.exe" ... <1 internal line>
If it is not critical you can change your jdk version. I've changed from jdk14 to jdk 11. Hope it will work for you.
Got same problem, and tried to solve it as was written above.
But then i got another solution of problem without changing settings.
Press mouse right button on your file where you put break point and want to debug. Then choose "Debug ur file name.method()".
Don't use debug button from tools window. Seems the problem is that Idea can't understand which file u want to debug.
That worked for me without changing async settings.
Screenshot
Got the same problem, and tried to solve it as was written all the above methods.
But still, I wasn't able to debug my file the only reason is that before debugging your program you need to set debug point that till which point we want to debug. So just click on the place shown in the figure and set debug point then our program will debug easily. without doing anything else. enter image description here
Java version must be 9 or higher.
Today I found the same question as you.
Situation: debug while set no breakpoint
Solution: set at least one breakpoint before you click debug button!
You have to put the red dots at the left side of the code line you will make debug .
if not you get this massage on IntelliJ

Intellij IDEA Remote Debug invalid breakpoints

Hello, everybody!
I am trying to debug my java8 application running on tomcat 7 with Intellij IDEA Remote Debug.
The problem is when i run debug in idea all off my breakpoints are set to invalid with message:
Line numbers info is not available in class pathToClass
Here is my JAVA_OPTS settings from catalina.bat:
set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999 %JSSE_OPTS%"
Here is my remote debug settins from IDEA
At one point in your build process your Java code is compiled in to classes with the javac compiler (or something equivalent). There is an option to the compiler to include debug information (including line numbers) which you apparently do not have enabled at the moment.
For plain javac add -g.
For ant add debug="true" to the javac task.
For Maven, the default configuration for the maven-compiler-plugin adds debug information, so the explicit setting not to has to be undone.
At one point in your build process your Java code is compiled in to
classes with the javac compiler (or something equivalent). There is an
option to the compiler to include debug information (including line
numbers) which you apparently do not have enabled at the moment. How
do you compile your code? – Thorbjørn Ravn Andersen
Adding debug="true" option to javac solving this problem.
Thanks everybody who helped.
I had the same problem. But the accepted answer did not solve it for me. In my case, the root cause was an interference caused by clover gradle plugin.
To debug the issue, I compared the source code of class A.java with the decompiled code of A.class. The decompiled version had a bunch of junk generated by clover. I just removed the clover plugin from the project, deleted the build folder, invalidated the cache and restarted IDEA. I added the breakpoint and ran it in debug. Voila! It worked this time.
It may not be clover in your case; It could be something else. But, most probably, this breakpoints issue is caused by a mismatch between your source code and compiled class. The best way to verify is to compare the decompiled class with its source.
This can be caused by the minify. Go to your Gradle and set:
Enabled=false
buildShrinkResources=false
Then sync and debug again.
Just had a problem like that, lines were out of sync with a remote server, although the connection was established(I was able to see thread list in IDEA).
The first thing I tried was to put breakpoints not on statements, but on the whole method. Debug hit the breakpoint, but in a weird place(on closing curly brace).
All I had to do, is to remove one empty line from the start of my file, and everything just got aligned with remote.

eclipse annotation processor not working. Where are errors shown?

Although there are other answers that cover this in some way, I want to have it for someone else that has similar problem and does notice the solution.
After setting up my own annotation processor and it properly working via maven, I got annoyed by being forced to rebuild source with maven on each change that needs the processor to do some magic.
Setting up eclipse to use my annotation processor required me to close annotation processor project so m2e-apt can put processor jars into .factorypath .
But then it stopped working for some reason, and I could not find the reason,
The solution to see the problem was to open:
Window->show view->General->Error Log
After seeing exceptions I was able to fix problems and get it working.
This is also the place where you'll see mesages from your processor
The answer above is correct, but I'd like to put here more details about how to work logging in Eclipse + APT.
Eclipse takes into account only messages send through processingEnv.getMessager().printMessage. If you use printMessage without reference to an element the Eclipse will route your log message to the Workspace Log (Window -> Show view -> General -> Error Log). If you use the printMessage with element reference the Eclipse will route your message to the Problems view (Window -> Show view -> General -> Problems).
If there is some exception during APT rounds Eclipse will log it into the Workspace Log (Window -> Show view -> General -> Error Log)
Eclipse will ignore any other logging methods (e.g. log4j, slf4j, etc).

IntelliJ IDEA: ClassNotFoundException if run Debug, execution/run does work

I have a Java Maven Project started in Eclipse, worked on it a few days, then imported it in IntelliJ IDEA, again working on it a few days.
The normal Run/Execution in IDEA and via shell does work, but not the Debug.
When I click the Bug Icon for Debug, it opens up URLClassLoader.java file and points on the Line "throw new ClassNotFoundException(name)" and pauses the Debug, if I click Resume Debug, it shows several Classes that do not belong to my project. I can click the Resume Button endless, it shows the same classes, also ClassNotFoundException over and over again in a continuously loop and does not debug my source.
If I click Build -> Rebuild Project it says at the Debug icon
"Hot Swap failed
myClassname: schema change not implemented;
myClassname: Operation not supported by VM"
In the Debug window under Variables it says: "Frame is not available"
The Debug of this project in IntelliJ IDEA did work previously, whats wrong now?
Looks like you have an exception breakpoint on ClassNotFoundException. Please try to open Run | View Breakpoints... and uncheck the breakpoint under "Java Exception Breakpoints".
in my situation, just neglect the evaluate language drop down.
This is really helpful. Go to your breakpoints in debug mode and make sure to deselect all the breakpoints first and then select only the ones in your class.

Eclipse debugging "source not found"

I just started using Eclipse so go easy on me ;). But when trying to debug a JUnit test case I get a dialog that states the the source is not found when I get to this line in the code in my test method:
Assert.assertEquals(1, contents.size());
I know I should probably go and try and download the source from somewhere, but I really don't want to because I have no interest in stepping into the JUnit code. I have the JUnit runtime jar so Why does Eclipse expect me to have all the referenced tools source code in order to debug my own code (seems somewhat silly)?
My main question is though, how can I tell Eclipse to skip this dialog when the source is not available and allow me to continue to debug my own code?
[Edit]
I've isolated the cause of this. It seems that Eclipse seems to think it needs the source when an exception is thrown by the internal JUnit code. In general is there anyway to tell it that it doesn't and just have it throw up an error dialog of some kind instead?
I had this very annoying problem for a long time but was finally able to solve it. In my case, a null pointer exception was being thrown somewhere in Java's Transformer.IsRuntimeCode(ProtectionDomain) function.
I didn't really need to know about this since the exception was being caught and handled, but eclipse would pause debugging every time this happened and tell me that the source wasn't available. As a result, I constantly had to keep pressing the button to continue code execution.
In order to prevent this from happening, I:
Clicked on the "Breakpoints" window
at the bottom of the debugging
screen
Right clicked "NullPointerException"
Unchecked "Caught"
This prevented the debugger from pausing program flow during a caught NullPointerException.
(source: SharpDetail.com)
The debug callstack will display a JUnit source code line when throwing an exception.
But you should not need to worry about that, if you do not have the source code of JUnit.
If you go back one line in the callstack, you should see the line (of your source code) which has caused the JUnit exception.
That should be enough to debug your code.
To associate the source with JUnit, you could add the junit.jar in the librairies of your project, and associates the junit-x.y.z-src.jar to the junit-x.y.z.jar, like so:
That will generate in the .classpath of your project a line like:
<classpathentry kind="lib" path="junit-x.y.z.jar" sourcepath="junit-x.y.z-src.jar">
Note: actually, there would be the full path of the junit[...].jar files in this classpathentry line. But you could also use Linked resources to avoid that fixed value (the full path) in your .classpath file.
I had a similar problem. I fixed it by right clicking on the project folder in the package explorer and selecting refresh. The code source was out of sync with the debugger and this corrected it. The Transformer.IsRuntimeCode(ProtectionDomain) Source not found message no longer appears.
Calculate contents.size() on a separate line instead or set a breakpoint on the method.
Also note the junit view in Eclipse allows you to navigate the stack trace.
Use the Step Filter to avoid stepping through the ...junit... packages. Right click on the stack trace and choose Filter Package. You may have to turn on filtering first with Use Step Filters. ~~~
I had a similar problem with another jar, even when I pointed to the source it would ask for it again. I was able to solve it by compiling the jar with debug="on" on ANT.

Categories