Eclipse - 由于缺少行号属性而无法安装断点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/957822/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse - Unable to install breakpoint due to missing line number attributes
提问by chandrajeet
I am getting this strange error in Eclipse while trying to set a breakpoint.
我在 Eclipse 中尝试设置断点时遇到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
I ticked the checkbox from Compiler options but no luck.
我勾选了编译器选项中的复选框,但没有运气。
回答by Zefiro
I had the same error message in Eclipse 3.4.1, SUN JVM1.6.0_07 connected to Tomcat 6.0 (running in debug-mode on a different machine, Sun JVM1.6.0_16, the debug connection did work correctly).
我在 Eclipse 3.4.1 中有相同的错误消息,SUN JVM1.6.0_07 连接到 Tomcat 6.0(在另一台机器 Sun JVM1.6.0_16 上以调试模式运行,调试连接确实工作正常)。
Window --> Preferences --> Java --> Compiler --> Classfile Generation: "add line number attributes to generated class file"was checked. I did a clean, recompile. I did uncheck it, recompile, check it, recompile. I made sure the project did use the global settings. Still the same message.
窗口 --> 首选项 --> Java --> 编译器 --> 类文件生成:“将行号属性添加到生成的类文件”已选中。我做了一个干净的,重新编译。我确实取消选中它,重新编译,检查它,重新编译。我确保该项目确实使用了全局设置。还是一样的消息。
I switched to ant build, using
我切换到 ant build,使用
<javac srcdir="./src/java" destdir="./bin" debug="true">
Still, same message.
仍然,同样的消息。
I didn't find out what caused this message and why it wouldn't go away. Though it seemed to have something to do with the running Tomcat debug session: when disconnected, recompiling solves the issue. But on connecting the debugger to Tomcat or on setting new breakpoints during a connected debug session, it appeared again.
我没有发现是什么导致了这条消息以及为什么它不会消失。虽然它似乎与正在运行的 Tomcat 调试会话有关:断开连接时,重新编译可以解决问题。但是在将调试器连接到 Tomcat 或在连接的调试会话期间设置新断点时,它再次出现。
However, it turned out the message was wrong: I was indeed able to debug and set breakpoints, both before and during debugging (javap -ldid show line numbers, too). So just ignore it :)
然而,事实证明消息是错误的:我确实能够在调试之前和期间调试和设置断点(javap -l也确实显示了行号)。所以请忽略它:)
回答by Zefiro
- In eclipse menu, go to Window->Preferences->Java->Compiler
- Unmark checkbox "Add line number attributes..."
- Click Apply -> Yes
- Mark checkbox "Add line number attribute..."
- Apply again.
- Go happy debugging
- 在 eclipse 菜单中,转到 Window->Preferences->Java->Compiler
- 取消标记复选框“添加行号属性...”
- 单击应用 -> 是
- 标记复选框“添加行号属性...”
- 再次申请。
- 去快乐调试
回答by user584572
This fixed my issue:
这解决了我的问题:
- Window -> preferences -> server -> runtime environments
- Apache Tomcat -> edit
- Select a JDK instead of JRE
- 窗口 -> 首选项 -> 服务器 -> 运行时环境
- Apache Tomcat -> 编辑
- 选择 JDK 而不是 JRE
回答by Paizo
For Springrelated issues consider that in some cases it generate classes "without line numbers"; for example a @Service
annotated class without an interface, add the interface and you can debug. see herefor a complete example.
对于Spring相关问题,请考虑在某些情况下它会生成“没有行号”的类;例如一个@Service
没有接口的带注释的类,添加接口就可以调试了。有关完整示例,请参见此处。
@Service("SkillService")
public class TestServiceWithoutInterface {
public void doSomething() {
System.out.println("Hello TestServiceWithoutInterface");
}
}
The service above will have an interface generated by spring causing "missing line numbers". Adding a real interface solve the generation problem:
上面的服务将有一个由 spring 生成的接口,导致“缺少行号”。添加一个真实的接口解决生成问题:
public interface TestService {
void doSomething();
}
@Service("SkillService")
public class TestServiceImpl implements TestService {
public void doSomething() {
System.out.println("Hello TestServiceImpl");
}
}
回答by Richard Le Mesurier
I have the answer to this problem from the BlackBerry SDK side of things: For some reason, no matter how many times I changed the options in the compiler, the actual underlying settings file did not change.
我从 BlackBerry SDK 方面给出了这个问题的答案:出于某种原因,无论我在编译器中更改了多少次选项,实际的底层设置文件都没有改变。
Have a look in the .settings folder of your project for a file called org.eclipse.jdt.core.prefs.
在项目的 .settings 文件夹中查看一个名为org.eclipse.jdt.core.prefs的文件。
In there you can modify the settings manually:
在那里您可以手动修改设置:
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
edit: Further to this, I have noticed that sometimes I can ignore the alert Eclipse gives, and it will still stop at the required place... curioser and curioser... I put this into the bucket of things we learn to deal with when working as dev.
编辑:除此之外,我注意到有时我可以忽略 Eclipse 发出的警报,但它仍然会停在所需的位置……curioser 和 curioser……我把它放到了我们学习处理的事物的桶中作为开发人员工作时。
回答by Binu N Kavumkal
This worked for me:
这对我有用:
- Under
Window --> Preferences --> Java --> Compiler --> Classfile Generation
, all options have to be toTrue
. - Made
debug="true"
in the build.xml<javac>
task. - Deploy application in the tomcat by the war generated by ant
- Restarted the Tomcat in
Debug
mode
- 在 下
Window --> Preferences --> Java --> Compiler --> Classfile Generation
,所有选项都必须是True
。 - 提出
debug="true"
在build.xml<javac>
任务。 - 通过ant生成的war在tomcat中部署应用
- 以
Debug
模式重启Tomcat
回答by jayaram S
Dont know if this is still relevant, perhaps another sailor will find this useful.
不知道这是否仍然相关,也许其他水手会发现这很有用。
The message appears when one has a class file compiled the debug flags turned off.
当一个类文件编译关闭调试标志时,会出现该消息。
In eclipse, you can turn it on by the afore mentioned options,
在 Eclipse 中,您可以通过上述选项将其打开,
Window --> Preferences --> Java --> Compiler --> Classfile Generation: "add line number attributes to generated class file"
窗口 --> 首选项 --> Java --> 编译器 --> 类文件生成:“将行号属性添加到生成的类文件中”
But if you have a jar file, then you would get the compiled output. There is no easy way to fix this problem.
但是如果你有一个 jar 文件,那么你会得到编译后的输出。没有简单的方法来解决这个问题。
If you have access to the source and use ant to get the jar file, you may modify the ant task as follows.
如果你可以访问源码并使用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" >
Happy debugging..
调试愉快..
回答by gbshuler
I tried almost every solution here and no luck. Did you try clicking "Don't tell me again"?After doing so I restarted my program and all was well. Eclipse hit my breakpoint as if nothing was wrong.
我在这里尝试了几乎所有解决方案,但没有运气。 您是否尝试单击“不要再告诉我”?这样做之后,我重新启动了我的程序,一切都很好。Eclipse 击中了我的断点,好像没有任何问题。
The root cause for me was Eclipse was trying to setup debugging for auto-generated Spring CGLIB proxy objects. Unless you need to debug something at that level you should ignore the issue.
我的根本原因是 Eclipse 试图为自动生成的 Spring CGLIB 代理对象设置调试。除非您需要在该级别调试某些内容,否则您应该忽略该问题。
回答by VonC
It would help if you did indicate the version of eclipse you are using and the technology (Java JDT, or AJDT for Aspect Java, or C++ CDT for instance), just to be sure.
如果您确实指出了您正在使用的 eclipse 版本和技术(Java JDT,或 AJDT for Aspect Java,或 C++ CDT,例如),这将有所帮助,只是为了确定。
On the Java side, I suppose your "Ticked the checkbox from Compiler options" refers to this
在 Java 方面,我想你的“从编译器选项中勾选复选框”是指这个
Under "Window --> Preferences --> Java --> Compiler --> Classfile Generation
", all 'Class file
' generation options are set to True:
在 " Window --> Preferences --> Java --> Compiler --> Classfile Generation
" 下,所有 ' Class file
' 生成选项都设置为 True:
- (1) add variable attributes,
- (2) addline numbers,
- (3) add source file name,
- (4) preserve unused local variables.
- (1) 添加变量属性,
- (2) 添加行号,
- (3) 添加源文件名,
- (4) 保留未使用的局部变量。
Does your project have those checked only at the global level (windows Preferences) or at project specific level?
您的项目是否仅在全局级别(Windows 首选项)或项目特定级别进行了检查?
And are you sure the class opened (on which you try to set a breakpoint):
并且您确定该类已打开(您尝试在其上设置断点):
- is one of your sources (and not coming from a third party library)
- is a
.java
, not a.class
?
- 是您的来源之一(而不是来自第三方库)
- 是一个
.java
,不是一个.class
?
Try to clean everything and rebuild all, check for potential jar conflicts.
尝试清理所有内容并重建所有内容,检查潜在的jar 冲突。
回答by chrisjleu
I had this problem while attempting to start Tomcat in debugging mode from Eclipse. I had an ANT build file taking care of the compile and deploy. After setting the debug flag to true (as mentioned in other answers) and redeploying the application it worked fine:
我在尝试从 Eclipse 以调试模式启动 Tomcat 时遇到了这个问题。我有一个 ANT 构建文件负责编译和部署。将调试标志设置为 true(如其他答案中所述)并重新部署应用程序后,它工作正常:
<javac srcdir="./src/java" destdir="./bin" debug="true">
NOTE:if you've just added the debug flag and recompiled you still need to redeploy your applicationto the server since this is where Eclipse is debugging the class files. Very obvious but easy to spend an hour or so scratching your head and wondering why it's not working (trust me).
注意:如果您刚刚添加了调试标志并重新编译,您仍然需要将您的应用程序重新部署到服务器,因为这是 Eclipse 调试类文件的地方。很明显,但很容易花一个小时左右的时间挠头,想知道为什么它不起作用(相信我)。