在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
当前回答
我在Eclipse 3.4.1中有相同的错误消息,SUN JVM1.6.0_07连接到Tomcat 6.0(在另一台机器上以调试模式运行,SUN JVM1.6.0_16,调试连接正常工作)。
窗口——>首选项——> Java——>编译器——>类文件生成:“添加行号属性生成类文件”被选中。我做了一个干净的重新编译。我取消检查,重新编译,检查,重新编译。我确保项目使用了全局设置。还是一样的信息。
我切换到蚂蚁构建,使用
<javac srcdir="./src/java" destdir="./bin" debug="true">
同样的信息。
我不知道是什么导致了这条消息,为什么它不会消失。尽管这似乎与正在运行的Tomcat调试会话有关:当断开连接时,重新编译可以解决问题。但是在将调试器连接到Tomcat或在连接的调试会话期间设置新的断点时,它又会出现。
然而,事实证明消息是错误的:我确实能够在调试之前和调试期间调试和设置断点(javap -l也显示了行号)。所以请忽略它:)
其他回答
在使用Spring Tool Suite (STS)启动Java EE项目时,我们也会遇到这个消息,但是我们可以忽略这个消息,因为一切都很好。
我的情况与此类似:
我正在调试一个JUnit测试 我使用Mockito创建一个间谍,如在spyTask =间谍(new Task()) 我将断点放在我正在监视的类中(在Task.java中)
这个断点会生成问题中的错误,每次我运行Debug As…> JUnit测试
为了解决这个问题,我将断点“向上”移动到实际测试中(在TaskTest.java内部)。一旦执行停止,我将断点添加回原来的位置(在Task.java中)。
我仍然得到相同的错误,但点击“确定”后,断点工作正常。
希望这对大家有所帮助,
-gmale
我试图调试日志管理器,需要将jre更改为jdk,然后在“主”选项卡中选择这个jdk,调试配置的“Java运行时环境”|“运行时jre”,然后一切正常。
这里有详细的解释:
https://github.com/spring-projects/spring-ide/issues/78
只是为了将来参考,这是答案的相关部分(忽略引用Spring Boot应用程序的事实,在许多其他情况下行为是相同的):
Whenever you set a breakpoint in Eclipse/STS, the IDE tries to set the breakpoint in the VM if you launch an app. That is what happens in your case when you run the boot app in debug mode. For each class that gets loaded into the JVM, the IDE checks whether it needs to set a breakpoint or not. If it decides to set the breakpoint, the tries to do so (using the information from the breakpoint definition in the IDE, including its line number, since you usually set line breakpoints on a source file at a given line). This decision (whether to set the breakpoint on a given loaded class or not) checks the types that you set the breakpoint on, enclosing types, and inner classes. This makes sure that breakpoints for inner classes (even anonymous inner classes) are set to the JVM (and are not ignored). Spring Boot generates an inner class for your controller at runtime (this is the CGLIB generated inner class that appears in the error message). When the JVM loads that class, it tries to set the line number breakpoint of the enclosing type (for this inner class). Since the generated inner class doesn't have any line number information (it doesn't need to have line number information), setting the breakpoint fails for this inner class with the mentioned error message. When the IDE loads the enclosing type (your controller class itself), it also tries to set the line breakpoint and succeeds with that. This is visualized with the check marker on the breakpoint marker. Therefore you can safely ignore the error message that shows up. To avoid this error message to show up, you can go to the preferences (Java -> Debug) and disable "Warn when unable to install breakpoint due to missing line number attributes".
对于使用Tomcat服务器的Web项目,我通过以下步骤解决了这个问题。
打开窗口->显示视图->其他->服务器。 双击运行中的tomcat服务器。(打开tomcat服务器概述) 现在点击启动配置链接。 单击sources选项卡。 单击Add。 选择java项目 将显示您的所有项目。 选择打开“您要调试。” 保存配置并重新启动或构建应用程序。