PlayFramework 2.4.x ide debug - intellij-idea

Is that possible to debug in playframework 2.4.x ? (x = 3 in my case) ?
IntelliJ IDEA 14.1.5
I'm following this link/doc: https://www.playframework.com/documentation/2.4.x/IDE
Create a new Run Configuration – From the main menu, select Run ->
Edit Configurations Click on the + to add a new configuration From the
list of configurations, choose “SBT Task” In the “tasks” input box,
simply put “run” Apply changes and select OK. Now you can choose “Run”
from the main Run menu and run your application
You can easily start a debugger session for a Play application using
default Run/Debug Configuration settings.
No luck so far for IntelliJ IDEA. When run as / press debug it does not drop me to debug break-poitns in IDE in my controller code when I got my get/post requests.
UPDATE:
One more try with same result (see screenshot) with adding play2 debug configuration (following: https://www.jetbrains.com/idea/help/getting-started-with-play-2-x.html):
If I change 2.4.3 to 2.4.2:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")
or in: addSbtPlugin("com.typesafe.play" % "sbt-fork-run-plugin" % "2.4.3")
same result.Or if I put JVML levelt to java 7.
It will be hard to convince a team to migrate a project from tomcat to play :) No out-of-the box magic.
And that "Setting up Play fork run ... " massage in logs that eats all processors for many seconds makes it even harder.

Something weired happanes anyhow.
Inititally I have createad my project from Play Activator as typical scala-play project.
But now when I created it from IDE New->Project->Scala->Play 2.x, then it works with debugging on out of the box.
If one figures out what is difference would be nice (even if that guy is me, from the Future). Seems guys from JetBrains care more about IDE integratiion than guys from TypeSafe ;).
Maybe the reason is in plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")
that what my IDE uses by default.
Or maybe it has somethign to do with this routing and IoC
For now I'm suttisfied. Thinking that 2.4.x is not ready to be used (at least not in convicing someone in something).
Update
Comment the following out and breakpoints work again:
addSbtPlugin("com.typesafe.play" % "sbt-fork-run-plugin" % "2.4.6")

Related

Sigasi in Eclipse

I have just installed the Sigasi Studio pluginin Eclipse (version: Eclipse IDE 2018-12). When I try to launch it,to make a new VHDL file, I get the following:
The selected wizard could not be started. org/eclipse/lsp4j/Range
(occurred in com.sigasi.hdt.vhdl.ui.VhdlExecutableExtensionFactory)
org/eclipse/lsp4j/Range
How I could solve it, please?
Thank you in advance.
Thanks to the Sigasi support, I was able to solve the problem. They wrote me:
The lsp4j plugin version is to recent for the xtext version that ships
with Sigasi Studio 4.2. This issue has been resolved in the preview
channel of release 4.3. Therefore - if you wish to use the plugin
version of Sigasi Studio - I recommend to install the 4.3 preview
following the steps explained on
http://insights.sigasi.com/tech/preview.html.
That's all. Now, I would like to configure Sigasi with GHDL (as a compiler, when I run the project) and GTKWAVE (ad a waves viewer). How can I do that?
Thanks in advance.
SIGASI + GHDL + GTKWAVE (all in one)
It is very powerful combo that you can set up. ATTENTION i use macOS 10.13.6:
Step 1
Make sure you have both installed GHDL and GTKWAVE typing
$ which gtkwave
/usr/local/bin/gtkwave
$ which ghdl
/usr/local/bin/ghdl
Step 2
Open Sigasi an make new Project and create an additional compile.sh file with:
#!/bin/sh
PROJECT_NAME="PWM_Generator"
PROJECT_NAME_TB="PWM_Generator_tb"
WORKING_DIR="/Users/imeksbank/Dropbox/UMHDL"
/usr/local/bin/ghdl -a --workdir=$WORKING_DIR/work.ghdl $WORKING_DIR/$PROJECT_NAME/$PROJECT_NAME.vhd;
/usr/local/bin/ghdl -a --workdir=$WORKING_DIR/work.ghdl $WORKING_DIR/$PROJECT_NAME/$PROJECT_NAME_TB.vhd;
/usr/local/bin/ghdl -e --workdir=$WORKING_DIR/work.ghdl $PROJECT_NAME_TB;
/usr/local/bin/ghdl -r --workdir=$WORKING_DIR/work.ghdl $PROJECT_NAME_TB --vcd=$WORKING_DIR/$PROJECT_NAME/simulation.vcd;
now, be aware, for each project you create your own variables like
PROJECT_NAME
PROJECT_NAME_TB
WORKING_DIR
I use always Dropbox for such approach because then i can access via Windows as well.
And of course, there is a possibility to create custom variables in Sigasi -> External Tool Configurator -> Program -> compile_sh -> environment to pass them to make compile.sh independent. Here you have to deal with it by yourself =)
Step 3 .
Set up you External Tools Configurations to let shell script be executed by Sigasi Studio and create the .vcd file for gtkwave:
Click on currently created Project (in my case it is the PWM_Generator).
After that click on Run -> External Tools -> External Tools Configurations ....
Then go to the left sidebar and under Program create your own anchor like compile_sh.
Finally you have your route :
Program
--compile_sh
And now extend this anchor by a custom created shell script :
Main->Location gets ${workspace_loc:/PWM_Generator/compile.sh}
Main->Working Directory gets ${workspace_loc:/PWM_Generator}
Click Apply and Run and that's it !!! After this you can program VHDL / Verilog and compile via Run -> External Tools -> compile_sh having created .vcd. In your project appears the gtkwave file and there just double click and it starts. =)

Get null use System.getenv() in gradle

def CATALINA_HOME = System.getenv("CATALINA_HOME")
task t << {
println CATALINA_HOME
}
CATALINA_HOME is null when I run with idea (double click t from Gradle Project panel), but when gradle t is executed in terminal I get a correct path.
It seem this is only happen in OSX (my version is 10.11.14 El Capitan).
IntelliJ IDEA has problems with recognizing environment variables on OS X (not sure if on other systems as well). Please have a look at this post - it should solve the problem (some time ago I had similar issue and found it very useful).
Since the linked page no longer exists you can find it in the archive here. Thanks #AlexeyStepanov!
Want to add, that sometimes it insufficient for Intellij Idea to configure Run/Debug Configuration option of Environment variable.
Instead you need to set them in File -> Settings -> Build, Execution, Deployment -> Build Tools -> Runner -> Environment variables

pub serve not updating web unless I restart it

In IntelliJ there's a tab that says "Pub Serve", when I hit Ctrl + Shift + R, I can see plenty of output on the Pub Serve output terminal and it launches the Chromium that came with the Dart Editor displaying my web application.
Now if I make a change to any of the dart files or html files or even index.html and refresh in Chromium, I don't see the changes until I click the stop button on Pub Serve.
I've installed the JetBrains plugin in Chromium to see if it makes a difference, non whatsoever.
Running pub serve from command line does exactly the same, until you kill it and re-run pub serve, your changes doesn't become visible.
Any idea on how I can have pub serve automatically reload upon code changes?
Update:
I think this could be related: https://code.google.com/p/dart/issues/detail?id=21402
It seems the problem is caused by Safe Write, there's a temp workaround:
WEB-13739 Pub Serve on Mac OS doesn't notice that file contents
changed, so refresh in browser shows old cached contents In DartEditor
you can work like this:
Start debug (this will start pub serve which takes a while).
Edit template in polymer element
Save (Now DartEditor does something to recompile the polymer template, AFAIK it does not do a full restart of pub serve because it
is faster).
Refresh browser, you see the change in the template.
But in Webstorm 9 EAP October 8 version, this workflow is not
possible. I have to kill pub serve and restart in order to see my
change in the polymer component's template. I would like Webstorm to
work the same as DartEdtior so I can have the same save/refresh
development cycle.
Workaround: uncheck 'safe write' mode in Preferences | Appearance &
Behavior | System Settings and vote for the corresponding issue in the
Google issue tracker.
https://youtrack.jetbrains.com/issue/WEB-13739
This workaround is relevant to IntelliJ Ultimate as well.
Vote for bug fix here:
https://code.google.com/p/dart/issues/detail?id=21402
Update
Bug was fixed:
This should be working now. The underlying issue was in the watcher
package, fixed here:
https://codereview.chromium.org/861313006/
Then pulled into the repo for pub and tested here:
https://codereview.chromium.org/801943005/
https://codereview.chromium.org/870703003/
Thanks Bob!

Debugging SBT project with Play in IntelliJ IDEA

I have a SBT project
in this project i have a sub play project and other projects
example from my build file :
lazy val subProj1 = Project(id = "sub-proj-1", base = file("sub1"))
.settings(...)...
lazy val subProjPlay = play.Project("play-proj", 1.0 , path = file("web"))
need to debug the play server from IntelliJ IDEA.
To run the project I use sbt run on the command line.
How can I debug the project in IDEA?
I found this to be the easiest solution : (using IntelliJ IDEA )
in IntelliJ :
Go to "edit run configurations"
Create a new remote configuration (port 9999, all other details leave with default values)
Go back to IntelliJ and run the new debug configuration (don't forget to put a break point)
From command line run :
sbt -jvm-debug 9999 run
The easiest solution.
Edit Configurations... -> add SBT Task (not Remote task).
Specify SBT Task: ~run.
Run created SBT Task using - Debug button
Provided you've Play distribution installed locally, use play debug run on the command line and connect to localhost on the port 9999 in IDEA.
From Debugging section in Using the Play console in the official Play 2.2.x documentation:
You can ask Play to start a JPDA debug port when starting the console.
You can then connect using Java debugger. Use the play debug command
to do that
If however you don't have it (and for a reason don't want to install it), add Remote Run configuration in IDEA that will give you a hint for the command line arguments you should be using when launching SBT, e.g.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
When you launch SBT that may or may not be as simple as launching SBT jar, just use the above to configure JVM to run in debug mode.
IntelliJ IDEA 2016.1.1 && Play Framework 2.5.3
For me, no matter how I set(create new Run/Debug Configuration for Play 2 App or SBT Task, specify the debug port, execute in Run or Debug mode) in the IntelliJ IDEA 2016.1.1 Enterprise Edtion, the IDEA can not open the debug port(default 9999), so the debug is impossible.
After disable the sbt-fork-run-plugin(comment it in /project/paly-fork-run.sbt), it works!!!
I am newer to Play framework,and have found many bugs...Compare to RoR, it's so hard to learn, to run, to use, to debug...
Below is my steps:
disable the sbt-fork-run-plugin(comment it in /project/paly-fork-run.sbt)
execute activator -jvm-debug 9999 "run 11111" (I use port 9999 to debug, port 11111 to run my Play project)
In IDEA, add an new Run/Debug configuration, Choose, set debug port to 9999
debug the new created configutation

Idea with PHP (not only) error handling & IDE jump-to-error-line

I have some idea with error handling in PHP - way to immediately get to place in code where error occurred.
I have written error handler to catch PHP errors, which loads file, that caused an error and displays +/- few lines of code from that file. It also mark line where error occurred and print stack trace, like this:
http://img834.imageshack.us/img834/3754/errh.png
Now, I have an idea, to provide some link (a href=) like other than http protocols (torrent:// or sth), like "netbeans://C:/some/file.php#110" which will put me back into NetBeans editor, open file where error occurred and put cursor in line, which caused a error.
Any ideas how to achieve that goal ?
What you need to do is register a custom url protocol. The techniques depend on the underlying operating system. here's is an example for windows. By opening NetBeans with a system call and the --open [filename] argument, you can open the file in question. However, that way you won't be able to go to a specific line.
In order to do so, you need to use the NetBeans API. If needed, you can use JNBridge to access Java functionality from .NET languages (which you'd need for windows).
All in all, it won't be easy and not cross-platform. A much easier way to go is to use xDebug on the server side and implement the library in the NetBeans editor, which will allow a lot more functionality than what you currently try to accomplish (stack traces, Jumping in Code, Stepping, variable views, ... - just to name a few). There seems to be a started proposal on this for the NetBeans editor.
If you do not care to switch the editor, you can check out Eclipse PHP Development Tools (Eclipse PDT), which has the debugger already implemented. Check out this article on the setup instructions.
I'd use xDebug with Netbean's xdebug integration which already jumps to the errors.
NetBeans IDE already has this option
Please open your project in NetBeans IDE.
main menu -> options -> editor -> hints -> select language php & select all check-boxes.
then refresh project show highlighting errors or undefined variables warnings.
if more with NetBeans IDE
http://netbeans.org/kb/docs/php/editorguide.html