Intellij: Debugging does not work with Play Framework - scala

I have problems for some time with debugging in Intellij (Ultimate 2019.2).
If I set Breakpoints and restart Intellij, or it reloads after a code change, all the Breakpoints work as expected:
But if I set the Breakpoints when the Play server is running, only a few of them still work:
Is this a bug, or is my configuration wrong?

Try this
File -> Invalidate Caches/Restart
Intellij keeps reloading stuff, breakpoints become active only when it's truly sure, no false positives here.
Usually I do, start the server then debugger and make sure endpoints are active before I make the request.

As it worked with plain sbt (Thanks for the hint of #Gagandeep Kalra), I asked for support of Intellij:
https://youtrack.jetbrains.com/issue/SCL-16565#comment=27-3792469

Related

Breakpoints dont work Remote debugging Play/Activator

I just started with the Play Framework but to learn these kind of things it is amazingly convenient to be able to use breakpoints.
Now I figured quickly that when I run 'activator -jvm-debug 9888' I can connect my Intellij CE 14 to its debugger. That seems to work, console gets nicely printed on the webui 'standard out' but not in my Intellij even when it says it connected.:
'Connected to the target VM, address: 'localhost:9888', transport: 'socket''
But that is truly about it, no console messages are show or breakpoints get hit inside intellij
Anyone had the same problem before and knows how to solve it? (Googling didn't find me the answer!)
Greets
In your build.sbt try to add this line (with a capital T!):
fork in Test := false
For info see http://www.scala-sbt.org/0.13/docs/Forking.html

How to debug Eclipse's internal clases

I have a very strange problem with regards to contributing to Eclipse. I have modified bundle org.eclipse.jdt.internal.junit4.runner and just wanted to test it and try it, but for some strange reason my breakpoints in the bundle org.eclipse.jdt.internal.junit4.runner are not working. It sounds to me that there is an internal filtering that cause that these bundles are ignored for breakpoint.
Funny thing is when I add
System.err.println("Did you reach it?"); //$NON-NLS-1$
In the console I can see the text, but the breakpoint is not working...
Any advice would be very welcome.
Look here. Also check whether any packages are excluded in Windows->Preferences->Java->Debug->Step filtering.
Well, I found out the problem but not a complete answer.
The problem is especially related to the org.eclipse.jdt.internal.junit4.runner bundle which launches and an another virtual machine and the code within this VM is not in debug mode, e.g. the first virtual machine is in debug mode and the second is not and that was the reason why my breakpoints did not work. So I guess there is no possibility how to enable debug mode "by eclipse automatically" in the subsequent VMs.
Here is an example of 2 VM from my blog http://blog.chocolatejar.eu/contribution/2014/02/27/better-visualization-junit-failures/

Service code debugging question with GWT 2.1

I recently attempted to set new breakpoints in eclipse to debug service side code in GWT. For some reason eclipse refused to see the breakpoints or the new code changes I had made. In the debugger it would open up what appeared to be an ear file from somewhere. Even though I had deleted the old ears, compiled and redeployed the new ear files. We are using GWT 2.1, JBoss 4.3, java 1.6 and Eclipse Helios. Finally, when I created a new environment with the code from scratch it started working. Any ideas as to what was holding on to the old code? BTW, I had rebooted my machine and restarted eclipse, but it also didn't make any difference.
Thanks,
James
Current state of debugging GWT apps is ... well not really good. Sometimes it's incredibly slow (development mode), sometimes lot of rubbish stays at webserver.
This might not solve your problem directly, but here are some advices from me:
Writing new client code (/client) at GWT means refreshing browser
Writing new server code means "Reloading web server". You have little yellow "refresh" button in Eclipse in "Development Mode" tab. This should reflect all the changes done at server side.
Embedded Jetty works usually well with GWT debugging. If you are not doing something jboss-server-specific, it should also work fine at production server. Just make sure your unit tests pass ;-)
You can ofcourse debug GWT application on external server, see this section of documentation (I guess you do on JBoss)
Be sure to remove all old files when reloading web server. It happened to me, that sometimes there were some weird old mixed up files (I was using Tomcat though). So you might want to write own clean script.
You must be absolutely sure that your serever code even launched! Use lot of GWT.log() at client side, that will ensure you in this. Don't worry, GWT.log are ommitted in production mode.
Be sure to inspect client-side page, it sometimes help to find out that your server code didn't manage to launch.
Log every public void onFailure(final Throwable caught) { of your AsyncCallbacks to get more info.
Don't use Google Chrome in development mode. It's MUCH slower than Firefox.
Otherwise, if you're using most recent version of your application, Eclipse must stop at breakpoint correctly.
I think JBoss was somehow caching things in it's temporary files and then I had forgotten about adding source in. This may be a JBoss thing as I don't recall seeing it with other application servers before.
So after I cleared out the cache, what got me thinking about the source was the fact that eclipse would stop on the breakpoints in the debugger that I had just set, but I couldn't see the source files.
Prior to this I was apparently hitting the breakpoints in the cached files and I couldn't alter them by setting new breakpoints. That was the root cause of the issue. Then by adding in the source from the ear, I got the debugger in sync with the code and it started working fine.

Eclipse skipping over breakpoints when debugging java

I've been using Eclipse for ages and I use the debugger all the time but recently I've known it to skip over breakpoints while debugging! I've even had it so that I've set a break point on a println I'll see the text come out but not hit the breakpoint. Also sometimes I'll hit a break point consistently in one area of the code but not in others. This never used to happen and I can't work out what I've done to my system to cause this. Has anyone else had any experience of the problem?
What you mention ("-XX:+UseParallelGC") is a workaround for the bug found with jdk6u14 and 15.
As mentionned in "Eclipse SWING app: breakpoint hit only after an uncaught exception is thrown", it is fixed with jdk6u16.
Ahaha,
I've found the solution eventually after a long web trawl. I'm not sure why this happens but other people have seen the problem too and
Window -> Preferences -> Java -> Installed JRE's -> (edit your currently used JRE) -> Edit "Default VM Arguments" box and enter (w/o questionmarks) "-XX:+UseParallelGC"
Generally fixes the problem...
I encountered the same issue. My solution is, you do a clean on the project (Project->Clean) and build again(Project->Build All or Project->Build Project). Upon a successful build, Debug the project again. It will go through the code perfectly (in the proper way).

Hot Code Replace Failed (eclipse)

"Hot Code Replace Failed - add method not implemented".
I get this error message every time I change something in my test class (and save it).
Can't figure out what it means. Can somebody help?
Possibly, you have a test which is still running (in debug mode). Try finishing all tests (you can see them in the debug view: window->show view->debug) and try again...
See this thread:
This means you changed a class while it was debugging an application and it could not update the class for the application while it was running.
The error suggests you may be running an older JVM, i.e. pre-1.4.2 but this error can occur with any JVM if the change is incompatible with the previous version of the class.
Check carefully what JRE you are using in your debug session.
Also check you are deploying classes compiled with the debug attribute set. (see this thread)
Finally, as indicated here:
did you switch "Project->Build Automatically" off?
Hot code replacement works (only?) if automatic build is switched on...
I was running into this issues too. I found a build hiding in the backgound that was giving me fits. Check to make sure you have all tests/builds closed or completed. Nonetheless, you can still run the new code.
Whenever this error message appears it also gives options to terminate or restart. Select Terminate and it will terminate any running debug case which you are unable to locate.
if you have multiple projects involved, and multiple jre's installed, make sure all dependent projects are using the same javac/jre
Make sure your application server JRE and Eclipse JRE version should be same or else it will throw unsupported class version and hot code debug will not work.
I went to the same Problem,But my Debugging session ended hours ago.But still ECLIPSE error kept coming.
So I just simply restart the ECLIPSE IDE, then the problem just solved.