在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
当前回答
这里有详细的解释:
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".
其他回答
如果上述解决方案不起作用,并且你在做了spring bean注入后开始遇到这个问题,问题可能是你没有为注入类使用接口。尝试使用实现接口的类进行注入可以解决这个问题。下面是一个例子: 无法安装用于创建bean的断点问题
这招对我很管用:
在窗口——>首选项——> Java——>编译器——>类文件生成下,所有选项都必须为True。 在build.xml <javac>任务中使debug="true"。 通过ant生成的war在tomcat中部署应用程序 在Debug模式下重新启动Tomcat
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.
我有同样的错误与JBoss 7.1.. 我和泽菲罗做了同样的事。只是忽略了错误,我能够正常放置断点。 在我的情况下,我正在构建思想蚂蚁生成器,这是我的javac任务:
<javac
srcdir="${src.dir}"
destdir="${build.classes.dir}"
includeantruntime="false"
debug="${debug}"
verbose="false"
debuglevel="lines,vars,source"
source="1.6"
target="1.6">
<!-- Sppressing warning for setting an older source without bootclasspath
(see: https://blogs.oracle.com/darcy/entry/bootclasspath_older_source) -->
<compilerarg value="-Xlint:-options"/>
<classpath>
<fileset dir="${lib.dir}" includes="*.jar" />
<fileset dir="${jboss.lib.dir}" includes="**/*.jar" />
</classpath>
</javac>
在编译/构建jar时,我做了上面列出的所有事情-仍然有同样的问题。
最终,在启动服务器时,下面列出的jvmarg更改最终为我工作:
删除/注释了一堆与javaagent和bootclasspath相关的jvm参数。
<!-- jvmarg value=“${agentfile}” /-->
< !贾维德- lib /雷丁——>
<!-- jvmarg value=“-Xbootclasspath/a:/foo /-->
打开/取消注释以下行:
<jvmarg value= -Xdebug />
然后,当我启动服务器时,我就可以到达断点了。我怀疑javaagent在某种程度上干扰了Eclipse检测行号的能力。