无法在Intellij IDEA中设置Java断点

时间:2023-01-18 09:08:32

I'm trying to put breakpoints into the GoogleAppEngine sources (SDK 1.7.0) but IDEA Ultimate (11.0.2) just keeps telling me Warning: No executable code found at line 482 in class com.google.appengine.api.memcache.AsyncMemcacheServiceImpl.

我正在尝试将断点放入GoogleAppEngine源(SDK 1.7.0),但IDEA Ultimate(11.0.2)只是告诉我警告:在com.google.appengine.api.memcache类的第482行找不到可执行代码。 AsyncMemcacheServiceImpl。

I get this error message both when I run the code from unit tests and I start up the development server.

当我从单元测试中运行代码并启动开发服务器时,我收到此错误消息。

It's quite annonying. Anyway my sources are in an external (relative to both the IDEA home and the project home) directory, and my jar files are under the Appengine SDK lib dir.

这真是太过分了。无论如何,我的源代码位于外部(相对于IDEA主目录和项目主目录)目录,我的jar文件位于Appengine SDK lib目录下。

My jar files are added as project library to the module, and my sources are attached to this library. I was playing around with module dependencies as well, but without any luck. Finally I decided to put this library into Compile scope, but that was a bad idea since the SDK provides these jars at runtime, so I decided to fall back to Provided scope.

我的jar文件作为项目库添加​​到模块中,我的源文件附加到此库。我也在玩模块依赖,但没有任何运气。最后我决定把这个库放到Compile范围内,但这是一个坏主意,因为SDK在运行时提供了这些jar,所以我决定回到提供范围。

I also played with the export checkbox on the module dependencies tab, but I think this is irrelevant, according to the web help, export is only important when you have dependent modules and you want to make your library available in these modules as well.

我还使用了模块依赖项选项卡上的导出复选框,但我认为这是无关紧要的,根据Web帮助,只有当您拥有依赖模块并且您希望在这些模块中使您的库可用时,导出才很重要。

Anyway, this question arised 4 years ago also. So I'm wondering now whether is it really so hard to solve this issue?

无论如何,这个问题也出现在4年前。所以我现在想知道解决这个问题是否真的很难?

I'm very disappointed now. I didn't have any problems with IDEA so far... I saw that this problem arised to other people as well, so this is not unique I guess.

我现在非常失望。到目前为止,我对IDEA没有任何问题......我看到这个问题也出现在其他人身上,所以这不是我想的独特之处。

Any help is appreciated.

任何帮助表示赞赏。


I edited my question due to my javap experiments below: It seems that the classes and the sources are NOT out of sync. I checked out the 1.7.0 related revision from SVN, and I'm using the 1.7.0 SDK, so these should not be out of sync at all.

由于我的javap实验,我编辑了我的问题:似乎类和源不是不同步的。我查看了SVN的1.7.0相关版本,我使用的是1.7.0 SDK,所以这些版本根本不应该是不同步的。

15 个解决方案

#1


52  

I had similar problems and various attempts has been applied. Below is my usual steps:

我遇到了类似的问题,并且已经进行了各种尝试。以下是我通常的步骤:

  1. If you are using Maven dependencies, go to Maven Projects -> refresh
  2. 如果您使用的是Maven依赖项,请转到Maven Projects - > refresh
  3. If that does not work, Try top menu --> Build --> Rebuild Project
  4. 如果这不起作用,请尝试*菜单 - >构建 - >重建项目
  5. If that still doesn't work, try top menu --> File --> Invalidate Cache/Restart
  6. 如果仍然无效,请尝试*菜单 - >文件 - >无效缓存/重启
  7. If that still doesn't work, then $CATALINA_BASE/bin/catalina.sh stop, then start
  8. 如果仍然无效,则$ CATALINA_BASE / bin / catalina.sh停止,然后启动

After this, usually it covers 99% of the problems. Otherwise, Probably you will have to examine some other possibilities.

在此之后,通常它涵盖了99%的问题。否则,你可能需要检查其他一些可能性。

#2


15  

I had similar problem in Intellij. I was not able to put breakpoint on one of the code snippet, I changed the line number of the code and then i was able to put breakpoint. Looks like a bug in intellij

我在Intellij遇到了类似的问题。我无法在其中一个代码片段上放置断点,我更改了代码的行号,然后我能够放置断点。看起来像intellij中的一个错误

#3


6  

I found some other cases where people reported that IDEA says "No executable code found". A common pattern is that they were trying to debug code that has been built without debug information. Check that you are compiling with the "-g" flag (or equivalent) set.

我发现了一些其他人报告IDEA说“没有找到可执行代码”的案例。一种常见的模式是他们试图调试没有调试信息的代码。检查您是否使用“-g”标志(或等效)集进行编译。

#4


3  

The question is rather old but I thought my experience might help someone in the future. In my case I was trying to debug code that was not compiled with debug information. I am using maven in which the original parent pom file before modification looked something like below in the build section.

这个问题相当陈旧,但我认为我的经历可能有助于将来的某些人。在我的情况下,我试图调试未使用调试信息编译的代码。我正在使用maven,其中修改前的原始父pom文件在构建部分中看起来如下所示。

<build>
    <pluginManagement>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.1</version>
            <configuration>
              <target>${javaCompilerVersion}</target>
              <source>${javaCompilerVersion}</source>
              <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <!--More plugins...-->
     </pluginManagement>
</build>

I changed the above section to make it look like below.

我改变了上面的部分使它看起来像下面。

<build>
    <pluginManagement>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.1</version>
            <configuration>
              <target>${javaCompilerVersion}</target>
              <source>${javaCompilerVersion}</source>
              <encoding>UTF-8</encoding>
              <debug>true</debug>
              <debuglevel>lines,vars,source</debuglevel>
            </configuration>
        </plugin>
        <!--More plugins...-->
     </pluginManagement>
</build>

Note the added <debug> and <debuglevel> elements. debuglevel element can take any combination of the three arguments separated by commas.

请注意添加的 元素。 debuglevel元素可以使用逗号分隔的三个参数的任意组合。

After compiling with this change I finally managed to put break points in IDEA.

在编译完这个改变后,我终于设法在IDEA中设置了断点。

#5


1  

I had a similar problem and it was caused by a mistake in my Tomcat configuration, under the Deployment tab, the "Deploy at the server startup". I had accidentally changed it to a very similar project with ":war exploded". When I changed it back, it worked fine.

我有一个类似的问题,它是由我的Tomcat配置中的错误导致的,在Deployment选项卡下,“在服务器启动时部署”。我不小心把它变成了一个非常类似的项目,“战争爆炸”。当我把它改回来时,它工作得很好。

#6


1  

Please, make sure you have not run Proguard. It helped me.

请确保您没有运行Proguard。它帮助了我。

#7


1  

Menu --> File --> Invalidate Cache/Restart

菜单 - >文件 - >无效缓存/重启

This worked for me under IntelliJ 13.0.2

这在IntelliJ 13.0.2下适用于我

#8


1  

If you are using some servers they will go into "low memory mode", that means they will not debug for you, no matter what options or caches you invalidate.

如果您使用的是某些服务器,它们将进入“低内存模式”,这意味着无论您使用哪种选项或缓存,它们都不会为您调试。

You should stop your server, increase the memory settings on the options that are passed to java and restart your server. Check logs to ensure you don't get a report such as "running in low memory mode".

您应该停止服务器,增加传递给java的选项的内存设置并重新启动服务器。检查日志以确保您不会收到诸如“在低内存模式下运行”的报告。

#9


1  

Had same issue, figured out that the version of code on the server and the one I'm debugging are different. After synching the code the issue was resolved.

有同样的问题,发现服务器上的代码版本和我正在调试的代码版本是不同的。同步代码后问题得到解决。

#10


1  

The essence of the problem is that the JVM executes a class file (either simple class or a class loaded from jar from the class path) which DOES NOT MATCH the source being used by debugger. Once this is understood, the solution is simple: make sure that the source represents the class being executed. So, to fix the problem you can refresh-synchronize sources to classes, etc.

问题的实质是JVM执行一个类文件(简单类或从类路径从jar加载的类),它与调试器使用的源不匹配。一旦理解了这一点,解决方案很简单:确保源代表正在执行的类。因此,要解决问题,您可以刷新 - 将源同步到类等。

#11


1  

I was able to fix this problem by recompiling the class in question: Build - > Recompile (filename.java)

我能够通过重新编译有问题的类来解决这个问题:Build - > Recompile(filename.java)

#12


0  

In my case I killed all running processes on the device and disconnected and reconnected it.

在我的情况下,我杀死了设备上的所有正在运行的进程,并断开连接并重新连接它。

#13


0  

I had the same issue using debug configuration in my case Tomcat. I tried all above, but nothing. when I just reconfigured the Tomcat (debug > edit configuration > remove the tomcat > add it again from scratch) it was finally working :)

我在Tomcat中使用调试配置时遇到了同样的问题。我尝试了以上所有,但没有。当我刚刚重新配置Tomcat(调试>编辑配置>删除tomcat>从头再次添加它)它终于工作了:)

#14


0  

Check your disc space and free up some memory. If you are running low on disc space, even if your server is not on "low memory mode", intelliJ would not allocate the space to cache the classes required for debugging. As a result it won't allow you to set the break-point.

检查您的光盘空间并释放一些内存。如果您的磁盘空间不足,即使您的服务器没有处于“低内存模式”,IntelliJ也不会分配空间来缓存调试所需的类。因此,它不允许您设置断点。

#15


-2  

Reboot your PC. It solved my case. simple is the best..

重新启动电脑。它解决了我的情况。简单是最好的..

#1


52  

I had similar problems and various attempts has been applied. Below is my usual steps:

我遇到了类似的问题,并且已经进行了各种尝试。以下是我通常的步骤:

  1. If you are using Maven dependencies, go to Maven Projects -> refresh
  2. 如果您使用的是Maven依赖项,请转到Maven Projects - > refresh
  3. If that does not work, Try top menu --> Build --> Rebuild Project
  4. 如果这不起作用,请尝试*菜单 - >构建 - >重建项目
  5. If that still doesn't work, try top menu --> File --> Invalidate Cache/Restart
  6. 如果仍然无效,请尝试*菜单 - >文件 - >无效缓存/重启
  7. If that still doesn't work, then $CATALINA_BASE/bin/catalina.sh stop, then start
  8. 如果仍然无效,则$ CATALINA_BASE / bin / catalina.sh停止,然后启动

After this, usually it covers 99% of the problems. Otherwise, Probably you will have to examine some other possibilities.

在此之后,通常它涵盖了99%的问题。否则,你可能需要检查其他一些可能性。

#2


15  

I had similar problem in Intellij. I was not able to put breakpoint on one of the code snippet, I changed the line number of the code and then i was able to put breakpoint. Looks like a bug in intellij

我在Intellij遇到了类似的问题。我无法在其中一个代码片段上放置断点,我更改了代码的行号,然后我能够放置断点。看起来像intellij中的一个错误

#3


6  

I found some other cases where people reported that IDEA says "No executable code found". A common pattern is that they were trying to debug code that has been built without debug information. Check that you are compiling with the "-g" flag (or equivalent) set.

我发现了一些其他人报告IDEA说“没有找到可执行代码”的案例。一种常见的模式是他们试图调试没有调试信息的代码。检查您是否使用“-g”标志(或等效)集进行编译。

#4


3  

The question is rather old but I thought my experience might help someone in the future. In my case I was trying to debug code that was not compiled with debug information. I am using maven in which the original parent pom file before modification looked something like below in the build section.

这个问题相当陈旧,但我认为我的经历可能有助于将来的某些人。在我的情况下,我试图调试未使用调试信息编译的代码。我正在使用maven,其中修改前的原始父pom文件在构建部分中看起来如下所示。

<build>
    <pluginManagement>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.1</version>
            <configuration>
              <target>${javaCompilerVersion}</target>
              <source>${javaCompilerVersion}</source>
              <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <!--More plugins...-->
     </pluginManagement>
</build>

I changed the above section to make it look like below.

我改变了上面的部分使它看起来像下面。

<build>
    <pluginManagement>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.1</version>
            <configuration>
              <target>${javaCompilerVersion}</target>
              <source>${javaCompilerVersion}</source>
              <encoding>UTF-8</encoding>
              <debug>true</debug>
              <debuglevel>lines,vars,source</debuglevel>
            </configuration>
        </plugin>
        <!--More plugins...-->
     </pluginManagement>
</build>

Note the added <debug> and <debuglevel> elements. debuglevel element can take any combination of the three arguments separated by commas.

请注意添加的 元素。 debuglevel元素可以使用逗号分隔的三个参数的任意组合。

After compiling with this change I finally managed to put break points in IDEA.

在编译完这个改变后,我终于设法在IDEA中设置了断点。

#5


1  

I had a similar problem and it was caused by a mistake in my Tomcat configuration, under the Deployment tab, the "Deploy at the server startup". I had accidentally changed it to a very similar project with ":war exploded". When I changed it back, it worked fine.

我有一个类似的问题,它是由我的Tomcat配置中的错误导致的,在Deployment选项卡下,“在服务器启动时部署”。我不小心把它变成了一个非常类似的项目,“战争爆炸”。当我把它改回来时,它工作得很好。

#6


1  

Please, make sure you have not run Proguard. It helped me.

请确保您没有运行Proguard。它帮助了我。

#7


1  

Menu --> File --> Invalidate Cache/Restart

菜单 - >文件 - >无效缓存/重启

This worked for me under IntelliJ 13.0.2

这在IntelliJ 13.0.2下适用于我

#8


1  

If you are using some servers they will go into "low memory mode", that means they will not debug for you, no matter what options or caches you invalidate.

如果您使用的是某些服务器,它们将进入“低内存模式”,这意味着无论您使用哪种选项或缓存,它们都不会为您调试。

You should stop your server, increase the memory settings on the options that are passed to java and restart your server. Check logs to ensure you don't get a report such as "running in low memory mode".

您应该停止服务器,增加传递给java的选项的内存设置并重新启动服务器。检查日志以确保您不会收到诸如“在低内存模式下运行”的报告。

#9


1  

Had same issue, figured out that the version of code on the server and the one I'm debugging are different. After synching the code the issue was resolved.

有同样的问题,发现服务器上的代码版本和我正在调试的代码版本是不同的。同步代码后问题得到解决。

#10


1  

The essence of the problem is that the JVM executes a class file (either simple class or a class loaded from jar from the class path) which DOES NOT MATCH the source being used by debugger. Once this is understood, the solution is simple: make sure that the source represents the class being executed. So, to fix the problem you can refresh-synchronize sources to classes, etc.

问题的实质是JVM执行一个类文件(简单类或从类路径从jar加载的类),它与调试器使用的源不匹配。一旦理解了这一点,解决方案很简单:确保源代表正在执行的类。因此,要解决问题,您可以刷新 - 将源同步到类等。

#11


1  

I was able to fix this problem by recompiling the class in question: Build - > Recompile (filename.java)

我能够通过重新编译有问题的类来解决这个问题:Build - > Recompile(filename.java)

#12


0  

In my case I killed all running processes on the device and disconnected and reconnected it.

在我的情况下,我杀死了设备上的所有正在运行的进程,并断开连接并重新连接它。

#13


0  

I had the same issue using debug configuration in my case Tomcat. I tried all above, but nothing. when I just reconfigured the Tomcat (debug > edit configuration > remove the tomcat > add it again from scratch) it was finally working :)

我在Tomcat中使用调试配置时遇到了同样的问题。我尝试了以上所有,但没有。当我刚刚重新配置Tomcat(调试>编辑配置>删除tomcat>从头再次添加它)它终于工作了:)

#14


0  

Check your disc space and free up some memory. If you are running low on disc space, even if your server is not on "low memory mode", intelliJ would not allocate the space to cache the classes required for debugging. As a result it won't allow you to set the break-point.

检查您的光盘空间并释放一些内存。如果您的磁盘空间不足,即使您的服务器没有处于“低内存模式”,IntelliJ也不会分配空间来缓存调试所需的类。因此,它不允许您设置断点。

#15


-2  

Reboot your PC. It solved my case. simple is the best..

重新启动电脑。它解决了我的情况。简单是最好的..