简体   繁体   English

Eclipse Debug:远程调试时找不到源

[英]Eclipse Debug: Source Not Found while remote debugging

In my Java eclipse project, while I am remote debugging, eclipse does not step into the class files of imported library files even though the source file jars are properly mapped to the library files. 在我的Java eclipse项目中,当我进行远程调试时,即使源文件jar正确映射到库文件,eclipse也不会进入导入库文件的类文件。

Instead it gives me a " Source Not Found " error. 相反,它给了我一个“ 未找到来源 ”错误。 But when I am editing the same class in eclipse, I can control-click a class or method name and it takes me to the correct library class file. 但是当我在eclipse中编辑同一个类时,我可以控制 - 单击一个类或方法名称,它会将我带到正确的库类文件。

Can anyone please tell me what I am doing wrong? 谁能告诉我我做错了什么?

I am using Tomcat 6 and latest Eclipse Java EE. 我正在使用Tomcat 6和最新的Eclipse Java EE。

In this scenario just follow the following steps: 在这种情况下,请按照以下步骤操作:

  1. Go to Run → Debug Configurations 转到运行→ 调试配置
  2. Select the remote application configuration being debugged. 选择要调试的远程应用程序配置。
  3. Select the second tab named 'Source' 选择名为“Source”的第二个标签
  4. Now add the folder/projects containing the source code explicitly here. 现在在这里显式添加包含源代码的文件夹/项目。

In the Java build path for the project, under the sources tab, check if your class path is under the included list. 在项目的Java构建路径中,在sources选项卡下,检查您的类路径是否在包含列表下。 If its under the excluded list, remove it from there. 如果它在排除列表下,则从那里删除它。

As Saury said, get your debug configuration right. 正如Saury所说,让你的调试配置正确。 When remote debugging, often developers have selected the wrong project while creating a new configuration. 远程调试时,开发人员通常在创建新配置时选择了错误的项目 Verify you select the project you wish to debug and it corresponds to the version of the deployed WAR/EAR/JAR in the appliation container. 验证您是否选择了要调试的项目,它对应于应用程序容器中已部署的WAR / EAR / JAR的版本。

I faced same issue and got solved by below steps in eclipse. 我遇到了同样的问题,并在eclipse中通过以下步骤解决了。

  1. Go to Severs tab in your Eclipse tab 转到Eclipse选项卡中的Severs选项卡
  2. Right click on the server and click on Add and Remove Projects 右键单击服务器,然后单击“ 添加和删​​除项目”
  3. Select/add the project EAR which you want to debug 选择/添加要调试的项目EAR
  4. After finish - Start your server in debug mode 完成后 - 以调试模式启动服务器

Should solve with above steps as it resolved for me:) 应该解决上面的步骤,因为它解决了我:)

I ran into a similar problem. 我遇到了类似的问题。 It turns out I was missing the devel package on CentOS. 事实证明我错过了CentOS上的开发包。

In my particular case, the following yum statement solved the problem. 在我的特定情况下,以下yum语句解决了这个问题。

yum install java-1.7.0-openjdk-devel

Follow the next steps in case you use a parent project connected to sub-project/s: 如果您使用连接到子项目的父项目,请执行以下步骤:

Use the ' Debug Cofigurations ' source tab or the ' Edit Source LookUp path ' option to attach the sources of the running code. 使用“ Debug Cofigurations ”源选项卡或“ Edit Source LookUp path ”选项附加正在运行的代码的

Note: you'll need to attach the src folder of your inner project rather than the target in order to make it work (check the screenshot below). 注意:您需要附加内部项目的src文件夹而不是目标 ,以使其工作(请查看下面的屏幕截图)。

Eg 例如

在此输入图像描述

An update for eclipse Oxygen (Feb 2018): eclipse Oxygen的更新(2018年2月):

Attaching the Java projects (sub projects) also worked well; 附加Java项目(子项目)也运行良好; eg: 例如:

在此输入图像描述

检查选择正确项目的“调试配置” - >“远程Java应用程序” - >选项卡“连接” - >“项目”。

Here is how it worked for me. 这是它对我有用的方式。 Did this on Eclipse oxygen 这是在Eclipse氧气上做的吗

  1. Go to debug configurations and then the source tab 转到调试配置,然后转到源选项卡
  2. Click on Add 单击“添加”
  3. Select Java Library. 选择Java Library。 Hit ok 点击确定
  4. The select Web app libraries and click next 选择Web应用程序库,然后单击下一步
  5. In the next screen select the project/application that you are debugging. 在下一个屏幕中,选择要调试的项目/应用程序。
  6. Click Finish 单击完成

This worked for me like a charm 这对我来说就像一个魅力

Using Eclipse version Oxygen.2 (2017), the accepted answer did not work for me. 使用Eclipse版本Oxygen.2(2017),接受的答案对我不起作用。 The following procedure was successful. 以下程序成功。

  1. Launch the application to debug with the Xdebug and Xrunjdwp switches. 启动应用程序以使用XdebugXrunjdwp开关进行调试。

    cd "C:\\Program Files\\Test_742\\Test 7.4" test_app.exe -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8500

  2. Create a new workspace in Eclipse. 在Eclipse中创建一个新工作区。

  3. Create a new Java project using File -> New -> Java Project. 使用File - > New - > Java Project创建一个新的Java项目。

  4. Copy the source code of the Jar to debug to the src folder of the new project. 将Jar的源代码复制到调试到新项目的src文件夹。 I found it necessary to ensure that I copied the complete folder hierarchy of the source code to my source folder. 我发现有必要确保将源代码的完整文件夹层次结构复制到源文件夹中。

    For me that meant copying \\com\\test... to my src folder. 对我来说,这意味着将\\ com \\ test ...复制到我的src文件夹。

    This puts all the source code in the build path. 这将所有源代码放在构建路径中。

  5. Copy any dependency JARs to the project. 将任何依赖项JAR复制到项目中。 I created a new folder named myJARs. 我创建了一个名为myJARs的新文件夹。

  6. Refresh Package Explorer to see the new myJARs folder. 刷新包资源管理器以查看新的myJARs文件夹。

  7. Add the dependency JARs to the build path by opening File -> Properties -> Java Build Path -> Libraries (tab), and click Add JARs... 通过打开文件 - >属性 - > Java构建路径 - >库(选项卡),将依赖项JAR添加到构建路径,然后单击添加JAR ...

    Add each dependency JAR to the list, then click Apply and Close. 将每个依赖项JAR添加到列表中,然后单击“应用并关闭”。 This adds the JARs to Referenced Libraries. 这会将JAR添加到引用的库中。

  8. Configure a debug session. 配置调试会话。 Click Run -> Debug Configurations -> Remote Java Application. 单击运行 - >调试配置 - >远程Java应用程序。 I set Connection Type = Standard . 我设置Connection Type = Standard

    Configure Host to point to the machine running the JAR and Port to the port specified in the address portion of the command line switches (8500 in my example). 配置主机以指向运行JAR和端口的计算机到命令行开关的address部分中指定的端口(在我的示例中为8500)。

  9. Notice that on the Source tab, both the source files and the dependency JARs are present. 请注意,在“源”选项卡上,存在源文件和依赖项JAR。

  10. Click Apply, then Debug. 单击Apply,然后单击Debug。

  11. View the debugging perspective by clicking Window -> Perspective -> Open Perspective -> Debug. 单击Window - > Perspective - > Open Perspective - > Debug查看调试透视图。

  12. Place breakpoints in the source code. 在源代码中放置断点。

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

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