This bug seems to be fixed as of this commit. Update Intellij to get the new version.

If you can't update, a workaround to this is removing gradle aware make from the run process, and only build your code when you make a change (and not every time you start the debug)

Explanation to fix:

Hitting breakpoints in Kotlin JUnit test with an Android Gradle
project sometimes(*) does not work in Android Studio 3.1 beta.

(*) The issue is related to various threads running concurrently
with "dumb" mode background code, so the issue reproduces only
on certain configurations.

In a nutshell, the issue is as follows

* On one hand, gradle build finishes, fires an event ("buildFinished")
  that is processed "later" and that causes the IDE to enter "dumb" mode
  for a shot amount of time (about 300-500 msec on a somewhat up to date
  multi-core computer).

* On the other hand, once the JVM of the debuggee is started, breakpoints
  need to be resolved (on the debugger thread, through a call to
  com.intellij.debugger.engine.CompoundPositionManager.createPrepareRequests.
  This code calls into the "KotlinPositionManager.createPrepareRequests",
  which in turns calls into "PerFileAnalysisCache.analyze". That method
  returns "AnalysisResult.EMPTY" is the project is in dumb mode.
  This return value prevents callers from successfully resolving
  the source location into a breakpoint.

Given that the 2 code paths above execute on separate threads without
explicit synchronization, the "failed to resolve breakpoint" issue
occurs sporadically, to the point it happens 100% of the time on
certain configuration.

The fix is so wrap the kotlin breakpoint resolution code inside
a "runReadActionInSmartMode" so that the debugger thread "waits"
for "dumb" mode to terminates before trying to resolve breakpoint
locations.
Answer from LeoColman on Stack Overflow
🌐
Kotlin Discussions
discuss.kotlinlang.org › support
Tons of problems with the debugger and Kotlin - Support - Kotlin Discussions
June 17, 2019 - I am running on 2019.1.3 built on May 28th. Basically what happens is breakpoints are not detected, often IDE doesn’t stop and keeps running. Have to try a few times (rerun the app) to make it detect the breakpoints.
🌐
Kotlin Discussions
discuss.kotlinlang.org › support
Breakpoints not hit anymore on Windows - Support - Kotlin Discussions
January 25, 2018 - I have a weird problem that recently started (still need to figure out exactly when) in a project using Kotlin 1.2.20 / 1.2.21, Gradle 4.4.1 / 4.5, and kotlintest 2.0.7. For some reason, IntelliJ does not hit breakpoints anymore, but only on Windows: All breakpoints say “Breakpoint does not belong to any class”. The exact same project still works on Linux.
Top answer
1 of 1
2

This bug seems to be fixed as of this commit. Update Intellij to get the new version.

If you can't update, a workaround to this is removing gradle aware make from the run process, and only build your code when you make a change (and not every time you start the debug)

Explanation to fix:

Hitting breakpoints in Kotlin JUnit test with an Android Gradle
project sometimes(*) does not work in Android Studio 3.1 beta.

(*) The issue is related to various threads running concurrently
with "dumb" mode background code, so the issue reproduces only
on certain configurations.

In a nutshell, the issue is as follows

* On one hand, gradle build finishes, fires an event ("buildFinished")
  that is processed "later" and that causes the IDE to enter "dumb" mode
  for a shot amount of time (about 300-500 msec on a somewhat up to date
  multi-core computer).

* On the other hand, once the JVM of the debuggee is started, breakpoints
  need to be resolved (on the debugger thread, through a call to
  com.intellij.debugger.engine.CompoundPositionManager.createPrepareRequests.
  This code calls into the "KotlinPositionManager.createPrepareRequests",
  which in turns calls into "PerFileAnalysisCache.analyze". That method
  returns "AnalysisResult.EMPTY" is the project is in dumb mode.
  This return value prevents callers from successfully resolving
  the source location into a breakpoint.

Given that the 2 code paths above execute on separate threads without
explicit synchronization, the "failed to resolve breakpoint" issue
occurs sporadically, to the point it happens 100% of the time on
certain configuration.

The fix is so wrap the kotlin breakpoint resolution code inside
a "runReadActionInSmartMode" so that the debugger thread "waits"
for "dumb" mode to terminates before trying to resolve breakpoint
locations.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360003676199-Can-t-debug-any-Java-or-Kotlin-application
Can't debug any Java or Kotlin application – IDEs Support (IntelliJ Platform) | JetBrains
Setting a breakpoint on each print ... but does not stop at breakpoints. ... - Checked that breakpoints are unmuted - Invalidated caches - Tried both JRE 1.8 and JRE 10 to run the Debug Configuration · The problem persists on both Windows machines I'm working on, with separate IntelliJ instances, ...
🌐
GitHub
github.com › bazelbuild › intellij › issues › 2832
Breakpoint doesn't work for Kotlin in IntelliJ IDEA 2021.2 · Issue #2832 · bazelbuild/intellij
August 5, 2021 - Open rules_kotlin project and place a breakpoint in a test, such as testSrcJarGeneration in src/test/kotlin/io/bazel/kotlin/KotlinJvmBasicAssertionTest.kt, then debug the test class using the icon on the gutter. ... Actual: Test finished with all cases passed. With plugin 2021.07.13.0.1 in IntelliJ IDEA 2021.1.3, it works ...
Author   jameslan
🌐
GitHub
github.com › gradle › kotlin-dsl-samples › issues › 1040
KT-23526 - IntelliJ debugger ignores breakpoints in Kotlin scripts · Issue #1040 · gradle/kotlin-dsl-samples
August 14, 2018 - KT-23526 The debugger doesn't ignore breakpoints in class and object members so a workaround is to declare an object in the script and put the breakpoint there: Top-level breakpoint in line 10 above is ignored but the breakpoint in line ...
🌐
JetBrains
jetbrains.com › help › idea › debug-your-first-kotlin-application.html
Tutorial: Debug your first Kotlin application | IntelliJ IDEA Documentation
October 23, 2024 - After the debugger session has started, the program runs normally until a breakpoint is hit. When this happens, IntelliJ IDEA pauses the program, highlights the line at which the program is suspended, and shows the Debug tool window. The highlighted line has not been executed yet.
Find elsewhere
🌐
JetBrains
jetbrains.com › help › idea › using-breakpoints.html
Breakpoints | IntelliJ IDEA Documentation
2 weeks ago - Once the count completes, it resets and starts again. This means that if Pass count is set to 10, the breakpoint will work every tenth time it is hit. If both Pass Count and Condition are set, IntelliJ IDEA first satisfies the condition and then checks for Pass Count.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 22113723485458-Debugging-React-Native-Typescript-JSX-Kotlin-doesn-t-hit-breakpoints
Debugging React Native Typescript JSX + Kotlin doesn't hit breakpoints – IDEs Support (IntelliJ Platform) | JetBrains
October 21, 2024 - In the second video, as you can see, I added a local native module where the sample templates added just a multiply function and as you can see I put a breakpoint on kotlin function which IntelliJ should support 100% but it didn't even stopped the execution to let me check variables in that function, like that toAdd variable…I tried to add also debugger” line code because maybe it would make IntelliJ's debugger see it and stop execution but seems “debugger” is not recognized by Kotlin compilation… · And as I said in previous stop, if I am debugging so putting a breakpoint, the debugger should just see that breakpoint and stop the execution there… · Maybe there is something I have to configure somewhere in IntelliJ to make the debugger working properly and stop on any breakpoint there is.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 23019611189906-How-can-I-set-a-breakpoint-into-Kotlin-default-constructor
How can I set a breakpoint into Kotlin default constructor – IDEs Support (IntelliJ Platform) | JetBrains
December 2, 2024 - According to https://www.jetbrains.com/help/idea/using-breakpoints.html#set-breakpoints, you can set a breakpoint for the default class constructor by clicking on class declaration line · To suspend the program when the default constructor of a class is called, click the gutter at the line where the class is declared · However, it doesn't work with Kotlin files (.kt).
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 6796164198546-Intellij-not-stopping-at-breakpoints
Intellij not stopping at breakpoints – IDEs Support (IntelliJ Platform) | JetBrains
Hi all, I am running a spring boot java application in debug mode in intellij 2022.1.4 community edition. Unfortunately intellij doesn't stop at any breakpoint even if the restful api works prope...
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 203929830-debugging-Kotlin-Intellij-code
debugging Kotlin Intellij code – IDEs Support (IntelliJ Platform) | JetBrains
I've been able to set breakpoints at org.jetbrains.io.Responses.kt However, when I hit a breakpoint, it brings me to Responses.class, not Responses.kt. What's missing? Ditto other Kotlin classes I...
🌐
JetBrains
youtrack.jetbrains.com › issue › KTIJ-9831 › Breakpoints-wont-work-for-Kotlin-testing-with-JUnit
Breakpoints won't work for Kotlin testing with JUnit
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
youtrack.jetbrains.com › issue › KTIJ-9831
Jetbrains
December 27, 2021 - {{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
Top answer
1 of 4
10

I figured out what my issue was and I think the problem is specific to me and the nature of my application. Actually I should call it a self induced issue. Let me explain the nature of events.

  1. I have been using eclipse to develop and have a local install of weblogic instance. My application needs coherence cache server and I have few other JVM parameters that I pass when starting the domain. Therefore I had added a line at the start of the $DOMAIN_HOME/bin/setDomainEnv.sh file like so

    JAVA_OPTIONS="- Dtangosol.coherence.distributed.localstorage=false -Dtangosol.coherence.wka=devmachine and blah blah blah

  2. I switched to intellij and started working on this project and then configured the weblogic plugin and run configuration etc.

  3. I noticed that intellij adds a JAVA_OPTIONS in the startup/connection tab in Run/Debug Configurations like so

  1. However the JAVA_OPTIONS that was being passed by intellij was not being used by weblogic. I believe it was overridden with what was in the setDomainEnv.sh which is why I saw the following logs.

java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode) Starting WLS with line: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -client -Xms512m -Xmx512m -XX:MaxPermSize=256m -Dweblogic.Name=AdminServer -Djava.security.policy=/Users/dparupud/omw/oracle/middleware/weblogic_10.3.6/wlserver_10.3/server/lib/weblogic.policy -Dtangosol.coherence.distributed.localstorage=false -Dtangosol.coherence.wka=devmachine blah blah blah......

  1. When I went and removed the JAVA_OPTIONS from setDomainEnv.sh and restarted the server from intellij I saw the following log

starting weblogic with Java version: java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode) Starting WLS with line: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -client -Xms512m -Xmx512m -XX:MaxPermSize=256m -Dweblogic.Name=AdminServer -Djava.security.policy=/Users/dparupud/omw/oracle/middleware/weblogic_10.3.6/wlserver_10.3/server/lib/weblogic.policy - agentlib:jdwp=transport=dt_socket,address=127.0.0.1:65501,suspend=y,server=n

Now the log showed that the jdwp agent was in action. I did notice that I did not see that particular log before I asked the Question on SO but I thought maybe IntelliJ was doing something inside the covers because JAVA_OPTIONS was being passed and intellij does not allow you to mess with that ( it is readonly).

I guess I can either pass all my jvm parameters either from intellij or add the jdwp agent info in the setDomainEnv.sh.

Now I am able to debug.

2 of 4
5

To setup WebLogic debugging on IntelliJ:

  1. Find the WebLogic Debug Port: this is the port on WebLogic exposed for debugging. The default debug port is 8453 but if it was changed you can find it in the config.xml (under the config folder in your domain home) or the setDomainEnv.sh look for DEBUG_PORT (I assume it is .sh and not .bat as you appear to be using Mac OS X).

  2. Remote Debugger Configuration: go to the configuration and choose new, then select "Remote" ,type in any name that is sensible and under the port (orange block in image) type in the value you found in 1. For host (the green block) type localhost [a side note: you can connect to a remote server by typing that servers host name or IP if the debug port is exposed].

  3. Start debugger: Start the debug configuration you just setup, the debug window will pop up and if the port is correct it will say it has connected to remote host and you are good to go debugging.

--Edit 1--

Read your question again missed the part about you already having setup the remote config.

It may be missing the breakpoint if your program is multi-threaded the breakpoint may not be hit on the current thread you are on.

There is a drop down in the debugger when you have the remote configuration working where you should be able to select the thread to debug on.

-- Edit 2 --

Added the image for the remote debugger settings