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.
Related
I am using IntelliJ to debug a Java program. In my current case that happens to be IntelliJ itself -- to debug a problem in it -- but a similar problem occurred in the past with other code.
While single-stepping, at a certain point when stepping into a method, IntelliJ won't show the code that is being executed anymore. I am used to stepping through decompiled byte code when source is not available, but in this case IntelliJ won't show anything -- no source code, no byte code, nothing. This happens when stepping from RemoteExternalSystemProjectResolverImpl into GradleProjectResolver.
Quite suspiciously, the problem happens exactly when stepping from a class that comes from an UrlClassLoader, into a class from a PluginClassLoader.
I'm aware that the debugger will have problems associating the bytecode being executed with source code when the bytecode comes from a class loader of unknown nature, since there is no well-defined mechanism for that. Please note that I am totally fine with stepping through decompiled code. (Even stepping through bytecode instructions would be fine, but AFAIK IntelliJ does not support that). I'm not sure how to provide matching source code myself, so I'd rather see the bytecode to be sure I'm not seeing false information.
What I do not understand is why IntelliJ won't show me that bytecode. Unlike source code, the bytecode is avaiable since after all, it is being executed right now.
What should I do to make IntelliJ show the bytecode being executed?
Update: Steps to reproduce
Use IntelliJ to create an IntelliJ plugin project
create a new folder with an empty build.gradle file in it
Run a "guest" instance of IntelliJ in debug mode
Import the empty gradle project
In the "host" IntelliJ, go to RemoteExternalSystemProjectResolverImpl.resolveProjectInfo and set a breakpoint to the inner call to this.myDelegate.resolveProjectInfo
In the "guest" IntelliJ, hit the Gradle re-import button. It should hit the breakpoint.
Step into the function being called. This will show the frame on the stack, but no code -- not even raw or decompiled bytecode.
You are possibly debugging a library that had been compiled without debug infos. For this purpose, the Java compiler has the command-line option "-g".
I assume you do not understand what bytecode is. This is a bunch of numeric values which cannot be displayed in a similar manner as source code. You would not be able to read bytecode.
What you are usually seeing is decompiled byte code, which depends on the existence of debug infos.
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
I have atteched the source file to project. I want to debug a method of say ArrayList. I placed a breakpoint also in that method but on debugging it gives error -unable to install breakpoint in eclipse due to missing line number attributes.Its a desktop application.
Use the JDK system library instead of the JRE, the latter isn't compiled with the necessary debugging information.
Everything works fined, but suddenly eclipse stopped execute and junit tests or even main method, when i run them using run as - > Java application, run as -> junit test
It simply throws error
Caused by: java.lang.ClassNotFoundException: package.ClassName
whene ClassName - is class from where i trying to run method main.
It affect only one of my projects ... Different workspaces works fine, other project in same workspace works fine as well.
I'm sure if i recreate current project, error will gone. But the adjustments of this project in eclipse is really hard, so i want to avoid it.
Any clue?
The ClassName is not in the Class Path, if you start from console you should use -cp parameter , if from eclipse, please add ClassName to the sources of current(start) project.
Thanks to adarshr, I was able to look at the Problems window and determine that the build was failing because it could not find a class I had written.
I had used the MS TFS plugin to create a "shelveset" and it was supposed to have removed my pending changes in the process. However, this integration with the TFS snapin and Eclipse is obviously not well implemented, since the Eclipse project still thought the file existed and was complaining that it could not be compiled.
I went and manually deleted those "files" or "non-existing files" from the Eclipse project (that I thought I had removed with the shelveset action) and the problem was solved.
Also....
Another annoying things is that the Tomcat error I was getting by trying to debug within Eclipse was like this:
SEVERE: Error configuring application listener of class
com.CompanyName.ProjectName.servlet.StartupConfigListener
java.lang.ClassNotFoundException:
com.CompanyName.ProjectName.servlet.StartupConfigListener at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
In reality, there was no problem at all with StartupConfigListener.java!! The build failed due to the OTHER problems I mentioned above, and therefore I guess this was the first class it attempted to load and failed.... because the entire project hadn't been able to compile perhaps?
(Here's to hoping my next project is using Visual Studio instead of Eclipse!)
Ok, I finally figured it out. The problem was with installed JRE in eclipse setting. I was playing around with this setting and changed installed JRE to JDK, and for some reason it broke the eclipse project.
You can also try going back to the basics. Check your command line and VM args. I've had this situation where a VM arg I was passing in was a path to a file that had a space in the path, and I had forgotten to include the full path in quotes. So e.g., if my arg looked something like
-DFILE=C:\Documents and Settings\myfile
...I'd get a java.lang.NoClassDefFoundError caused by a java.lang.ClassNotFoundException.
I am trying to trouble shoot a JUnit. In the source code, I have set break point in two places: 1) in a line where a static member is initialized 2) the first line of one of the test cases.
The debugger stops in the static field initializing line. But it doesn't stop in the test case. No matter where I set the break point in the test case, the debugger doesn't stop there. I know for sure that the test case is executed as I can see the log messages that I have added appear in the log.
Any help would be greatly appreciated.
I am using Eclipse Galileo and JUnit4 launcher.
Fix could be as simple as clicking run/skip all breakpoints. Worked for me.
Make sure, under Run > Debug Configurations, that 'Stop in main' is selected, if applicable to your situation.
This could be related to one of the bugs in JDK 6 Update 14, as indicated in the release notes for JDK 6 update 15.
If this indeed turns out to be the issue, you should move to a higher version of the JDK (that's no guarantee though, since fixes have been released against 6u16, 6u18 and 7b1). The best bet is to use -XX:+UseParallelGC flag. Increasing the size of the minimum and maximum heap size, to delay the first GC, bring temporary relief.
By the way, use this bug report in Eclipse to track how others have been faring.
You might have accidentally skipped all break points in Eclipse toolbar. To fix this go to Eclipse -> Run -> Skip All Breakpoints.
Usually when this happens to me (rare but it does) means that the code being executed is different than the code in the editor. It will happen from time to time for Eclipse that the built classes and the code in editor are out of sync. When that happens I get all sort of weird debugger behavior (debugging empty lines, skipping lines of code etc).
Restarting Eclipse, clean all projects and rebuild everything usually clears things up. I had also the Maven plugins (older versions... had not had it for a while now) that had a tendency to do that too.
Otherwise it might be a bug, maybe the one Vineet stated,
Hope this helps
In my case the problem was that I hadn't Debug view open in Debug perspective, so:
1 - Be sure you have debug perspective opened:
2 - Be sure you have debug view opened:
Project -> Clean seemed to work for me on on JRE 8
In order to debugger work with remote, the java .class files must be complied along with debugging information. If "-g:none" option was passed to compiler then the class file will not have necessary information and hence debugger will not be able to match breakpoints on source code with that class in remote. Meanwhile, if jars/class files were obfuscated, then they also will not have any debug info. According to your responses, most probably this is not your case, but this info could be useful for others who face the same issue.
Remove all breakpoints and re-add them.
For JDK7, run->Debug Configurations, check "Keep JUnit running after a test run when debugging".
Happened to me once, when I had unchecked "Run > Build automatically" and forgot to re-check it.
Make sure you declare the package at the top.
In my groovy code this stops at breakpoints:
package Pkg1
import java.awt.event.ItemEvent;
isMule = false
class LineItem {
// Structure defining individual DB rows
public String ACCOUNT_CODE
public String ACCOUNT_DESC
...
This does not stop at breakpoints:
import java.awt.event.ItemEvent;
isMule = false
class LineItem {
// Structure defining individual DB rows
public String ACCOUNT_CODE
public String ACCOUNT_DESC
...
To remove the breakpoints:
Debug your class as a junit test
When your debugger stops, click the "breakpoints" tab next to "variables" and "expressions"
At the top right of the breakpoint tab, click the button with two 'X'
Stop the test, replace your breakpoint and run the debugger again
Also verify if breakpoints on other lines DO work, it may be a bug in the debugger. I have had a problem with the Eclipse debugger where putting a breakpoint on a boolean assignment whose code was on the next line didn't work I reported this here, but putting it on the previous or next line did.
If nothing works-
Remove that Remote/Local Debug Configuration, and Create a new One.
Add the Source in Debug Configurations.
Another possible problem is that the debugger port may be blocked by the firewall. For example, I was using mule anypoint studio (v 5.4.3). The default debugger port is 6666. When a flow is executed, it would not stop at breakpoint. when I changed the port to another (e.g. 8099), it worked fine.
Go to Right click->Debug Configuration and check if too many debug instances are created.
My issue was resolved when i deleted multiple debug instances from configuration and freshly started debugging.
If you are on Eclipse,
Right click on your project folder under "Package Explorer".
Goto Source -> Clean up and choose your project.
This will cleanup any mess and your break-point should work now.
Creating a new workspace worked for me.
In my case I had multiple projects in same workspace. The java file I was trying to debug was present in more than one projects with same package.
I didn't need the other project, so simply closed unrelated projects (or remove the file from unrelated project).
One additional comment regarding Vineet Reynolds answer.
I found out that I had to set -XX:+UseParallelGC in eclipse.ini
I setup the virtual machine (vm) arguments as follows
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Xms512m
-Xmx1024m
-XX:+UseParallelGC
-XX:PermSize=256M
-XX:MaxPermSize=512M
that solved the issue.
It happened to me when I had several project, I realized that I created a spring boot configuration of a project B from a project A (I clicked on Duplicate and change the parameter to have a config for the project B) and in that case I haven't the debug mode so I removed this config and I created directly a new one by clicking New in Spring Boot App
This is what works for me:
I had to put my local server address in the PHP Server configuration like this:
Note: that address, is the one I configure in my Apache .conf file.
Note: the only breakpoint that was working was the 'Break at first line', after that, the breakpoints didn't work.
Note: check your xdebug properties in your php.ini file, and remove any you think is not required.