15

I have an old Gradle project that I've opened recently using the new IDEA 2017 and I have just noticed it will not stop on breakpoints anymore (these are active, but not "validated" - no checkmark on them.

The code is run locally (a gradle run/debug config without any options) with bootRun as the gradle task.

I have tried an Invalidate Caches/Restart without any success. I have also tried re-importing the project in IDEA.

A while back I had the same issue after upgrading to Spring 1.4.5 (if I remember correctly). I couldn't figure out why, so I downgraded back to 1.4.2 and everything worked fine. However, this time I'm running Spring 1.2.4 and I cannot upgrade to a newer version without changing some code (and I don't want that yet)

CatalinM
  • 520
  • 1
  • 5
  • 20
  • Have you tried different solutions from this question: http://stackoverflow.com/questions/11591662/cannot-set-java-breakpoint-in-intellij-idea?rq=1 ? – Ivan Pronin Apr 09 '17 at 19:13
  • Yes, without success. When I start the project I get the expected ```22:21:01: Executing external task 'bootRun'... :compileJava UP-TO-DATE :bootRun Listening for transport dt_socket at address: 5005``` – CatalinM Apr 09 '17 at 19:21
  • I'm having this issue with maven failsafe. Not sure if it's because of failsafe or not. I'll have to investigate. Usually i use surefire, which has no such problem. – djangofan Dec 03 '18 at 00:05
  • No idea about those, but have a look at the ports your application/debugger is working on. That tipped me off about the source of the problem – CatalinM Dec 03 '18 at 07:40

7 Answers7

15

Confirm. Problem was that I try to debug using maven run configuration. Switching to Application configuration type helps. I've spend half of a day on it (

  • 4
    having same issue. can you expand on this? what do you mean by switching to application configuration? thanks – alltej Nov 07 '17 at 17:20
  • 3
    Run -> Edit Configuration - Plus -> Application ->Then point to main method – Andriy Yarish Feb 01 '18 at 10:50
  • 1
    Saved me after 2 hours of head scratching – Dark Star1 Aug 14 '19 at 14:00
  • My friend, thank you for sharing, but how do you expect others make full use of your answer if you don't share steps, or more clarification: how exactly do I switch to app mode?! – aero Oct 25 '19 at 15:19
  • Hi, I am also facing the same issue. But in my case, the project is an Spring-based project. So how to configure the Application config? – Jagan Dec 02 '19 at 14:02
6

Well... for some reason, creating a Gradle run/debug config would make it connect to the wrong port (something random over 50000) while the application was running on 8080.

Anyway, long story short, creating an Application run/debug config solved the issue and everything works fine now.

CatalinM
  • 520
  • 1
  • 5
  • 20
  • I wish I had found this before I wasted a load of time of trying to maven and spring profiles – Dave Apr 25 '21 at 20:35
1

I have faced this problem.

  1. Invalidate caches and restart
  2. I was using Spring Boot rest api project in intellij so all debug breakponts were getting passed/ignored. But the programm started debug process whenI hit Api using postman
0

This problem happens due to different reasons and you could find some of the answers on Intellij Community pages.

That being said, one of the most common reasons are build plugins. If you really don't need the build plugins you could disable them and try again:

enter image description here

Zstack
  • 4,046
  • 1
  • 19
  • 22
0

Although 2017.1 is long past this is the top answer for "intellij debugger not stopping at breakpoint java" so I'll add another tricky way to have this problem here and associated solution.

Another way to cause this is to set your gradle settings to run tests with gradle, and also have a configuration for your tests that does something like:

  doFirst {
    jvmArgs = [
        '--add-modules', 'ALL-MODULE-PATH',
        '--add-opens', 'java.base/java.lang.module=ALL-UNNAMED',
        '--add-opens', 'java.base/jdk.internal.loader=ALL-UNNAMED',

The mistake here is that this replaces ALL jvm args with the ones supplied including the args that IntelliJ passes to open the debugger port. The fix is just one character... use += instead of = like this:

  doFirst {
    jvmArgs += [
        '--add-modules', 'ALL-MODULE-PATH',
        '--add-opens', 'java.base/java.lang.module=ALL-UNNAMED',
        '--add-opens', 'java.base/jdk.internal.loader=ALL-UNNAMED',
Gus
  • 6,719
  • 6
  • 37
  • 58
0

The problem for me was that I was using bootrun as the command in Intellij's Gradle run config, instead of bootRun. Weirdly the application did start with the former, but it would not stop on any breakpoints. After switching to bootRun, breakpoints immediately started working.

ruohola
  • 21,987
  • 6
  • 62
  • 97
-1

If you are calling a rest api make sure the passed in param has the same fields as the param variable as shown here @PostMapping("/user") public ResponseEntity<?> updateUserProfile(@RequestBody UserDTO userDto) {

The passed in value for UserDTO obj should have the same instance variables list in the json passed.... also object reference from repos also should be checked.

user1419261
  • 829
  • 8
  • 5