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

Unable to insert breakpoint Absent Line Number Information

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


当前回答

以上这些都对我不起作用。 下面的解决方案终于奏效了。 调试配置->类路径->用户条目->(添加要调试的项目的src文件夹)

其他回答

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

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

不知道这是否仍然相关,也许另一个水手会发现这有用。

当已编译的类文件关闭调试标志时,将出现该消息。

在eclipse中,您可以通过前面提到的选项打开它,

窗口—>首选项—> Java—>编译器—>类文件生成:“添加行号属性生成类文件”

但是如果您有一个jar文件,那么您将得到编译后的输出。解决这个问题没有简单的方法。

如果您可以访问源代码并使用ant来获取jar文件,那么您可以如下所示修改ant任务。

  <javac  destdir="${build.destDir}" srcdir="${build.srcDir}" source="1.6" fork="true" target="${javac.target}" debug="on" debuglevel="lines,vars,source" deprecation="on" memoryInitialSize="512m" memoryMaximumSize="1024m" optimize="true"   >

快乐的调试. .

裁判: http://doc.sumy.ua/prog/Java/javanut/ch16_04.htm

在编译/构建jar时,我做了上面列出的所有事情-仍然有同样的问题。

最终,在启动服务器时,下面列出的jvmarg更改最终为我工作:

删除/注释了一堆与javaagent和bootclasspath相关的jvm参数。

<!-- jvmarg value=“${agentfile}” /-->

< !贾维德- lib /雷丁——>

<!-- jvmarg value=“-Xbootclasspath/a:/foo /-->

打开/取消注释以下行:

<jvmarg value= -Xdebug />

然后,当我启动服务器时,我就可以到达断点了。我怀疑javaagent在某种程度上干扰了Eclipse检测行号的能力。

这解决了我的问题:

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

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.