在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。

Unable to insert breakpoint Absent Line Number Information

我勾选了编译器选项的复选框,但运气不好。


当前回答

我的情况与此类似:

我正在调试一个JUnit测试 我使用Mockito创建一个间谍,如在spyTask =间谍(new Task()) 我将断点放在我正在监视的类中(在Task.java中)

这个断点会生成问题中的错误,每次我运行Debug As…> JUnit测试

为了解决这个问题,我将断点“向上”移动到实际测试中(在TaskTest.java内部)。一旦执行停止,我将断点添加回原来的位置(在Task.java中)。

我仍然得到相同的错误,但点击“确定”后,断点工作正常。

希望这对大家有所帮助,

-gmale

其他回答

在调试部署到Tomcat的WAR(由多个Eclipse项目构件构造)时,我遇到了同样的问题。

我正在使用ANT构建脚本构建所有内容。如果这是您正在做的事情,请确保在您获得的每个javac ant任务上设置了debug=true标志。这是我唯一的问题-我希望它能帮助你的问题!

If someone is trying to debug Java's source code, then, this is the only solution that worked for me. Most of the above answers talk about setting the Compiler option to generate line numbers.But, if want to debug Java's source code (say java.util.HashMap), then the above options may not work for you. This is because , the project from where you intend to debug the source code is having the Java Build Path --> Library --> JRE System Library pointing to the jre jar instead of the jdk jar. The classes bundled inside jre jar have already been pre-compiled with a specific option, that will not honor the Compiler option settings. Solution, is to reconfigure your project to have the JRE System Library point to the jdk jar. The classes inside your jdk jar will honour the Compiler option settings. So, once you update your project's JRE System Library to point to the jdk jar, debug on Java source code will start working.

我从黑莓SDK方面得到了这个问题的答案:出于某种原因,无论我在编译器中修改了多少次选项,实际的底层设置文件都没有改变。

在项目的.settings文件夹中查找一个名为org.eclipse.jdt.core.prefs的文件。

在那里你可以手动修改设置:

org.eclipse.jdt.core.compiler.debug.lineNumber=generate

编辑:除此之外,我还注意到有时我可以忽略Eclipse给出的警告,它仍然会停在需要的地方……越来越奇怪……我将此归入我们作为开发人员所需要处理的事情中。

我也遇到了同样的问题,我花了很多时间去寻找解决方案,但这些解决方案都是无用的,所以我自学了所有的案例,最后我发现问题是JDK版本之间的冲突。 以下是解决问题的步骤: 1. 删除所有JDK和JRE版本,只保留一个版本。 2. 在Eclipse中设置JAVA_HOME系统和java编译器是一样的。 在某些情况下,上面的错误不会消失,但我们能够运行在调试模型。

这解决了我的问题:

窗口->首选项->服务器->运行时环境 Apache Tomcat ->编辑 选择JDK而不是JRE