在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
当前回答
当我用@ManagedBean (javax.annotation.ManagedBean)注释类时,我发现了这个问题。在JBoss EAP 6.2.0上运行新编译的应用程序时出现警告消息。忽略它并继续运行并没有帮助——断点从未到达。
我在JSF页面中使用EL调用该bean。现在…@ManagedBean可能不适合(我是CDI的新手)。当我将注释更改为@Model时,bean执行了,但断点警告也消失了,我像预期的那样击中了断点。
总之,看起来@ManagedBean注释弄乱了行号,不管它是否使用了错误的注释。
其他回答
有一次我在使用junit和Mockito时遇到了同样的错误,我忘记为静态类添加@PrepareForTest。
添加以下代码修复了我的问题。
@PrepareForTest({XXXXX.class})
不确定是不是同一个案子。
对于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");
}
}
这招对我很管用:
在窗口——>首选项——> Java——>编译器——>类文件生成下,所有选项都必须为True。 在build.xml <javac>任务中使debug="true"。 通过ant生成的war在tomcat中部署应用程序 在Debug模式下重新启动Tomcat
从Spring AOP得到这个消息(似乎来自CGLIB库)。点击忽略似乎工作正常,我仍然可以调试。
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.