Setting breakpoints in a Java gradle project in Intellij - java

I have a Java gradle project in Intellij that I want to debug using breakpoints. When I press the green run button, everything runs fine. When I press the debug button, it still runs fine, but no breakpoints get hit. My run configuration looks like this:
I also tried setting the project to build and run using Intellij IDEA like this, but this did not help either (it also does not work when I select "gradle"):
What steps are needed to fix this? The last questions on this topic unfortunately did not manage to solve this problem.
I work with Intellij 2021.1.2 and gradle 6.8.

According to the comments posted by dan1st and CrazyCoder, what I was trying to do was not a good idea and it is better to debug the java project directly.

Have you tried enabling the "Debug all tasks on the execution graph" option? This help me to get debugging to work correctly

Related

Test runner tab disappeared in Intellij

When I try to run the tests by right-click and selecting "Run.."
It used to work until a few days ago. I use IntelliJ 2021, I tried an older version but I have the same issue, I tried uninstalling most of my plugins, nothing. I also tried searching through similar issues but nothing was of use.
This is how the Run Tab looks
In the Run tab, a list of running tests should be seen, but it is not. My project is a Maven project with Java and Gauge. Do you have any idea what the problem could be? My guess is I either pressed something by mistake or something else is doing this.
Nevermind, I just found the issue, please make sure to have
this checkbox
checked if you use Gauge.

Intellij break point report Method threw 'java.lang.ClassNotFoundException' exception even the variable exist

Anywhere I break, when I hover on variable or try to evaluate, IntelliJ always report:
Method threw 'java.lang.ClassNotFoundException' exception even the variable exist
I tried to clear cache and restart the IntelliJ as well as refresh Gradle cache and rebuild the app. Nothing work. But the application itself did not crash and runs as usually, so I am pretty sure its Intellij problem. But I can't find any solution online.
Also, the file is a Kotlin file.
First, I forgot to mention, this error came up when I was in JRebel debug mode.
For now, none of the existing solution worked. But I did the following:
1. I upgraded to later version of intellij (2019.3). everything stop running and all sort of error came up.
2. I reverted back to the version I was using (2019.2)
3. then I did rebuild with default debug mode icon (little red bug icon) then with jrebel debug mode icon (rocket with a grey bug). Only Jrebel debug mode have that error message!
I still did not know why jRebel acts like that suddenly, but at least this is a piece of information that may help lead to better solution than what I would have to do now ---- use default Intellij debug mode.... which is very very slow....
So likely you may not even need to take any of the above step, but simply try to build with the Intellij Debug mode to see if it still work so to isolate out that if its a JRebel problem.
Could you please open a JRebel Support ticket and we can then take a closer look at the issue?
You can open a ticket either from the JRebel IDE plugin or by sending an email to support#jrebel.com

Cannot set Break Point in Intellij-IDEA

I am running a Maven project and while trying to debug the application, in some lines I'm getting an error No Executable line found at <line no> error even though the code gets executed. I have tried File->Invalidate Cache / Restart method. Appreciate any solutions.
IntelliJ IDEA version: 2018.2.4
Thanks in advance.
Try checking what configuration you are running, I was having similar problem when I didn`t set the configuration right.
You can also use the Run with coverage to see where the code is going :)
Hope this was helpful.

How to rerun kotlin project when I update a file in Intellij IDEA

Ideally, in Intellij IDEA I'd like to be able to debug a java project, then have the IDE restart debugging the project when I edit a file. If that's not possible, a keyboard shortcut would help (something equivalent to the restart button in the debugger panel). Any ideas?
You could use ctrl+f5 to kill the current instance of your application, and rerun it.

I get "Source not found" when debugging my Java code in Eclipse

I'm trying to debug my Java application in Eclipse however when I hit a breakpoint I simply see the following instead of my source:
If I change the stack frame in the Debug window then I can see the function name change in the tab - this is definitely my code, the line number is correct and I'm using the latest build but I still can't get Eclipse to show the source (despite it being open in another tab!)
I'm new to Eclipse and so I'm struggling to find my way around, but everything that I've stumbled across so far seems fine to me.
What might cause this to happen and how can I fix it?
Sounds like the 'source lookup path' section if you edit the debug configuration isn't setup correctly?
Click on "Edit Source Lookup Path" button and then click on Add button then Java Project and include your imported project .. Hope this will solve your problem
I also had this issue in MyEclipse Blue. I resolved it by following these steps:
Debug the project.
Right click on the Thread (Which you will see in Debug tab) and click on the "Edit Source lookup"
New window will open and hit the "Add" button and Select the "Java Project".
Get all the project that is listed over there.
Restart your server.
I had similar problem with my eclipse maven project. I fought with this issue quite a long time then I tried to rebuild projet with
mvn clean eclipse:eclipse
and it helped.
When I faced this problem for the very first time, I've already done all the steps mentioned here. Curiously, my problem happened when I've copied a project into another place. Anyway, the debug starts to work without warnings, after simply remove all breakpoints that was originated from the original project.
Sorry about my English , I'm not fluent.
We had the same problem and none of the suggestions above worked. What did work, was deleting the local workspace and from Eclipse checking out from the repository again. The problem occured for everybody previously working with Netbeans and making the switch to Eclipse.
Try this:
Select Project
Right click
debug
Debug configuration
Select Source Tab
Click on add button
Select Java Project
Add your project there with check box
For local projects I've solved it by selecting the "Resolve Workspace artifacts" checkbox in the Debug Configurations.
This is a common error while debug in eclipse. You can fix it through edit source look up. But make sure once you attach the Project You need to stop the server and again start in Debug mode. It will work.
Here is the detail steps :
Click on "Edit Source Lookup Path" button .
Then click on Add button.
Select Java Project and include your imported project
Then stop the server and start it in Debug mode and hit your service. It will work.
After trying most of the solutions here, try this too once -
Close all the .java files from the editor, in fact, close all unrelated projects in eclipse.
And try running the Debugger.
I solved this problem by adding the class file into the src folder within the project. Hope this method may help.
I got this error when I was running my server using a maven tomcat plugin. When I deployed using my configured server in Eclipse (generating a war file and copying it into my tomcat directory), I didn't have this issue anymore.
In your debug configuration add goals as "clean install"in the maven build con
This is an expansion on JAB's answer:
Click "Edit Source Lookup..." > Add... > Workspace Folder > Project > select your folder > check Search subfolders box > OK.
In Eclipse:Window-->Go to preferences-->Java-->Click on JRE-->Edit--->Restore Default and click on Finish.
Update your Project before Debugging the code!
Alas! It worked for me.
This occurred to me when my working git branch is updated from code in master branch. I have already run mvn clean install after the pull, but seems I had to update projects after the maven build so that project source code and JAR build code gets synchronized.
Right click on your project -> Maven -> Update Project, then select all the
maven modules available and press OK. This resolved the issue for me.
I was facing same issue. After banging my head for several hours, I finally noticed that although Maven was building the project successfully, the source file I was trying to step into had an incorrect package statement and that is why the 'Source Not Found' eclipse problem was happening. When I corrected the package statement and rebuilt the project, the debugger found source file and stopped on my breakpoint.

Categories

Resources