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

Unable to insert breakpoint Absent Line Number Information

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


当前回答

我在Eclipse IDE中也有同样的错误。 但这似乎是一个可以忽略的错误。 我在错误对话框上按下Ok键,然后继续。 我的断点到达&我能够进一步调试。

其他回答

我也遇到过这个问题。我正在使用一个蚂蚁构建脚本。我正在开发一个遗留应用程序,所以我使用的是jdk版本1.4.2。这个方法曾经有用,所以我开始四处寻找。我注意到在JRE选项卡上的Debug配置下,Java的版本被设置为1.7。一旦我把它改回1.4,它就工作了。

我希望这能有所帮助。

我在试图从Eclipse以调试模式启动Tomcat时遇到了这个问题。我有一个ANT构建文件负责编译和部署。在将调试标志设置为true(如其他答案所述)并重新部署应用程序后,它可以正常工作:

<javac srcdir="./src/java" destdir="./bin" debug="true">

注意:如果您刚刚添加了调试标志并重新编译,那么仍然需要将应用程序重新部署到服务器,因为Eclipse就是在服务器上调试类文件的。很明显,但很容易花一个小时左右的时间挠头,想知道为什么它不管用(相信我)。

我在jetty服务器上使用ANT编译新的。war文件时也遇到了同样的问题。在你必须像之前写的那样设置Java compiler之后,你应该创建相同版本的jdk/jre编译器和构建路径(例如jdk 1.6v33, jdk 1.7, ....)。

我什么都做了,还是没工作。解决方案是删除已编译的.class文件和生成的war文件的目标,现在它的工作:)

这里有详细的解释:

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".

我有同样的错误与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>