Cannot set Java breakpoint in Intellij IDEA

2019-01-08 11:53发布

问题:

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.

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.

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.

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.

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

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.

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.

回答1:

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. If that does not work, Try top menu --> Build --> Rebuild Project
  3. If that still doesn't work, try top menu --> File --> Invalidate Cache/Restart
  4. If that still doesn't work, then $CATALINA_BASE/bin/catalina.sh stop, then start

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



回答2:

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



回答3:

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.



回答4:

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.



回答5:

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.

<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.

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



回答6:

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



回答7:

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.



回答8:

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



回答9:

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

This worked for me under IntelliJ 13.0.2



回答10:

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".



回答11:

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.



回答12:

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



回答13:

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 :)



回答14:

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.



回答15:

I was working on an Intellij Plugin and when the sandbox Intellij popped up, what finally fixed my issue was, once the sandbox intellij popped up, I rebuilt from there.

After that I built both my Intellij and the sandbox Intellij and they synced finally.



回答16:

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