简体   繁体   English

Java调试:找不到源代码

[英]Java Debugging: Source not found

I am having a problem with Eclipse where I can run my program just fine, but when I try to start the debugger, I get this message 我遇到了Eclipse的问题,我可以运行我的程序,但是当我尝试启动调试器时,我收到此消息

Eclipse窗口显示错误

The picture is a little hard to make out, but instead of getting the normal debugging window, instead it says it is throwing a ClassNotFoundException, and is trying to dislay the source for Launcher$ExtClassLoader. 图片有点难以理解,但它没有得到正常的调试窗口,而是说它抛出了一个ClassNotFoundException,并试图为Launcher $ ExtClassLoader显示源。

The thing that really baffles me though is that I can run the code just fine, it is only when I click the debug button that I have the problem. 真正令我感到困惑的是,我可以运行代码就好了,只有当我点击调试按钮时我才有问题。

I have also tried debugging at the command line with JDB, and I got the same error. 我也试过在JDB的命令行调试,我得到了同样的错误。

So far, I have tried Reinstalling Eclipse and downloading (what I believe to be) the correct Java Development tools for Mac OS X. 到目前为止,我已经尝试重新安装Eclipse并下载(我相信是)适用于Mac OS X的正确Java开发工具。

I have no idea what else I can try, so any help would be greatly appreciated. 我不知道我还能尝试什么,所以任何帮助都将不胜感激。 Let me know if there is any other information I can provide. 如果我能提供任何其他信息,请告诉我。

Source not found might be legitimate for dynamically loaded code (eg Maven). 未找到源可能对动态加载的代码(例如Maven)是合法的。

There are three workarounds known to me (after months of search): 我知道有三种解决方法(经过数月的搜索):

  1. Connect to a running JVM with the debugger and you will see the code. 使用调试器连接到正在运行的JVM,您将看到代码。

  2. Use Dynamic Source Lookup plugin for Eclipse from here: 从这里使用Eclipse的Dynamic Source Lookup插件:

    https://github.com/ifedorenko/com.ifedorenko.m2e.sourcelookup https://github.com/ifedorenko/com.ifedorenko.m2e.sourcelookup

  3. Use run-jetty-run Maven plugin 使用run-jetty-run Maven插件

    http://code.google.com/p/run-jetty-run/ http://code.google.com/p/run-jetty-run/

I prefer and recommend 3. It works and starts webapp much faster than jetty:run. 我更喜欢并推荐3.它比jetty工作和启动webapp要快得多:运行。

Unfortunately 2. didn't helped me as it has issues with Windows paths with spaces. 不幸的是2.没有帮助我,因为它有空格的Windows路径的问题。

I have filled an enhancement request on Eclipse Bugzilla and if you agree this issue "Source not found" should vanish forever, please vote for it here: 我已经在Eclipse Bugzilla上填写了一个增强请求,如果你同意这个问题“Source not found”应该永远消失,请在这里投票:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=384065 https://bugs.eclipse.org/bugs/show_bug.cgi?id=384065

Do you have the sources for the files that you are using. 您是否拥有所使用文件的来源。 If you are using Maven (M2Eclipse) you could download the sources. 如果您使用Maven(M2Eclipse),您可以下载源代码。 This might solve the problem. 这可能会解决问题。 在此输入图像描述

Otherwise you could go and manually attach your sources. 否则,您可以手动附加您的来源。 Here is how you manually attach sources. 以下是手动附加源的方法。

获取图书馆路径

Next you have to attach the sources- 接下来你必须附上资料来源 -

附加来源

Hope this helps 希望这可以帮助

The "source not found" is a red herring - there may simply be no way to get access to the source that is throwing the error, because it is deep in the guts of the debugger's class loader. “找不到源”是一个红色的鲱鱼 - 可能根本无法访问抛出错误的源,因为它深入调试器的类加载器。

The better question, then, is, "Why is scottrice.ChessPuzzles.ChessPuzzleDriver not being found?" 那么更好的问题是,“为什么没有找到scottrice.ChessPuzzles.ChessPuzzleDriver ?” The only possibility that occurs to me at the moment is that something might be weird in your debug configuration. 目前发生在我身上的唯一可能性是调试配置中可能有些奇怪。 Did you debug the program by just right-clicking a file with a main() and choosing "Debug As" -> "Java Application"? 您是否通过右键单击带有main()并选择“Debug As” - >“Java Application”的文件来调试程序?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM