在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
当前回答
对于Spring相关的问题,考虑在某些情况下它生成的类“没有行号”;例如,一个没有接口的@Service注释类,添加接口就可以调试了。请参见这里的完整示例。
@Service("SkillService")
public class TestServiceWithoutInterface {
public void doSomething() {
System.out.println("Hello TestServiceWithoutInterface");
}
}
上面的服务将有一个由spring生成的接口,导致“缺少行号”。添加一个真实的界面解决了生成问题:
public interface TestService {
void doSomething();
}
@Service("SkillService")
public class TestServiceImpl implements TestService {
public void doSomething() {
System.out.println("Hello TestServiceImpl");
}
}
其他回答
不知道这是否仍然相关,也许另一个水手会发现这有用。
当已编译的类文件关闭调试标志时,将出现该消息。
在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
我尝试了之前的大部分解决方案,但还是遇到了问题。 这就是我接下来所做的:
从Eclipse中删除应用程序 停止服务器 从webapps中删除应用文件夹 从服务器中的临时文件夹中删除内容 从服务器中的工作文件夹中删除内容 在Eclipse上重新打开应用程序 启动服务器
可能有些步骤是不需要的,但“以防万一”。
因此,如果前面的解决方案仍然不适合你。试试这个。 我希望这对你有所帮助;-)
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.
我在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也显示了行号)。所以请忽略它:)
我试图调试日志管理器,需要将jre更改为jdk,然后在“主”选项卡中选择这个jdk,调试配置的“Java运行时环境”|“运行时jre”,然后一切正常。