Debug Playframework 2.0 in Eclipse - eclipse

There's no eclipse folder in project folder after 'play eclipsify'. How to debug this project use eclipse with JPDA?

Since play 2.0, only thing need to do to debug a project is run project in console 'play debug run' and create a new debug conf of remote java application with port 9999

Exactly as fxp has said, in play 2.2.x you should do the following:
Type in the play console play debug run
In eclipse, right click over your project and go to Debug As, and then click on Debug configurations..
In Debug configurations screen, go and click to Remote Java Application.
Put 9999 in the port input text (*)
(*): when you execute play debug run, look the print information for the port number. Probably the first message will be
Listening for transport dt_socket at address: 9999

In Play 2.3.x, you need to start the application with:
activator -jvm-debug 9999 run
Then follow all the other steps in the other answers.
Setting up your preferred IDE

The socket port for debugging is 9999 in play 2.0

Another thing, you might need to create a unit test in Play to get the debug running.

Related

how to setup a debugger for AEM or CQ?

how to setup a debugger for AEM or CQ? I'm using Eclipse IDE and Maven 3.2.5 for build and AEM version 6.0. I'm new to AEM and Java.
This Adobe article walks you through it: https://helpx.adobe.com/experience-manager/kb/CQ5HowToSetupRemoteDebuggingWithEclipse.html
Step 1: Add the Remote Debugging JVM Parameter
To use remote debugging, you must start CQ5 with this JVM parameter:
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
You can add the parameter by doing the following;
Start your server like this: crx-quickstart/bin/start -d --debug-port 8000. The -d parameter adds the jvm parameter to the CQ5 java process.
Add it to your crx-quickstart/bin/start script CQ_JVM_OPTS environment variable (so your server always starts in debug mode).
Include it as a parameter when starting CQ5 with java -jar directly. For example, java -Xmx512m
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -jar cq-author-4502.jar
Notes
If necessary, you can change the port defined under "...,address=8000,..." from 8000 to something that works better in
your environment.
Starting CQ 5.5, using the last solution, when Quickstart forks a new process it does not start the JVM with the debug options. You can
prevent forking by specifying the -nofork command line option.
Te start script is located under crx-quickstart/server for CQ versions < 5.5
Step 2: Start a remote debugging session
To start a remote debugging session from Eclipse, do the following:
Open Eclipse.
Choose Run > Debug Configurations.
Right-click Remote Java Applications and select New.
Select your CQ5 project under Project.
Type in the port from the "address" configuration of the jvm parameter defined above. In the example, it is port 8000 (and the host
name of the machine you are connecting to, most likely localhost)
To start a debugging session, double-click your new configuration in the Debug Configurations screen after saving it.
Applies to: CQ 5.x and Adobe Experience Manager 6.x
If you're on windows follow these steps.
Open AEM crx-quickstart, move onto bin, open start.bat(Right click and edit), find default JVM options, add the line
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=3000 next to headless=true in the start.bat file, save it. Open cmd in the bin folder. Type start.bat and hit enter which will open the instance with debugging port 3000.
Open Eclipse. Add breakpoints to the java file. Run > Debug Configurations > Remote Java Application, right click and select New Configuration, provide a name, select project(the one with .core), change port to 3000, apply and debug. Change the perspective to Debug, Window > Perspective > Open Perspective > Other > Debug.
Open AEM Page containing the component which uses the java class for which the breakpoints have added. If you’ve added breakpoints for the HelloWorldModel.java, open the page with helloworld component or refresh if already opened. And that’s it, eclipse will notify and the program will be paused at the breakpoint.
Possible Errors you might encounter with:
Failed to connect to remote VM. Connection refused. Connection
refused: connect
The debugger has already started when you hit apply and debug and trying to run the debugger again will get you this error.
Debugger not pausing at breakpoints and no notification in eclipse.
If the instance was already running and you hit start.bat in cmd, you’ll find this unusuality. Close the instance, and enter start.bat(in the bin folder). You’ll find the message below when the instance is ready. It might or might won’t open the browser by its own. So just open the browser and enter http://localhost:[portnumber]/.
SUCCESSFULLY LOADED validation.properties via the CLASSPATH from ‘/ (root)’ using class loader for DefaultSecurityConfiguration class!
RAWProcessor succesfully installed
17.10.2019 12:59:41.437 *INFO * [main] Startup completed
Step1: Start AEM service in debug mode with -debug parameter and a port number.
Step2: Setup debug configuration in IDE with the above port.
References:
How to start AEM in debug mode?
CQ5How To Setup Remote Debugging With Eclipse

Doesn't work debug for play project in IDEA 14 Ultimate

I do following steps:
Import to IDEA Play project generated with Activator UI from Play Scala Seed template.
Create Run/Debug configuragion using standart "Play 2 App" template.
Add break point in my project.
Run debug and open page in a browser.
I can see in IDE console "play - Application started", and debugger tells me
"Connected to the target VM, address: '127.0.0.1:58354', transport: 'socket'"
But program execution doesn't stop at my break points. In a browser I can see
what a code for that I've made a break point is executed.
What's wrong with IDEA?
I use play version 2.3.9, and I start the play app from an IDEA ide not from a play console.
seems duplicate with :
How to run Play Framework 2.x in debug mode in IntelliJ IDEA?
Your first step seems wrong. Just open (and don't import) your project is enough from IntelliJ.

Missing 'debug' command from Play 2.0 installed from Typesafe

I installed play 2.0 from the typesafe stack.
However, when i try to run sbt debug run it gives me the error:
[error] Not a valid key: debug (similar: idea)
Any suggestions on how to run a debug server?
In order to debug with the sbt command instead of the play command, you have the option to set the env. variable SBT_OPTS with the classical
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999
Source : https://groups.google.com/forum/?hl=fr&fromgroups#!topic/play-framework/-RVlEh8S2F4
I spent quite some time on this tonight. Hope my experience helps.
And as many of you I am encountering same issue that debug is not recognized under sbt. The easiest way of course is to follow the documentation. install the Play standalone and run the play debug run command, and then debug remote java application using the 9999 port.
but #Julienlafont 's solution did workout as well (I had the confusion at first as well). The key is to understand the whole process. Play web server is still served through port 9000. but port 9999 is opened as debug port to let IDE connect to , this is important.
I guess the reason why debug is not recognized is because it is not a sub command at all. it is indeed a couple of JVM arguments as #Julienlafont point out. so the what play command did is simply wrap the JVM argument for you. note once you enter the play console, the debug extension wont be recognized, because its essence is a couple of JVM arguments.
so go ahead set that JVM argument, once you see the hint , you are done with opening the debug port. run your server and finish the remaining part.

Is it possible to debug PL/Java (ideally from Eclipse)?

Although I found PL/Java a powerful add-on for PostgreSQL, I couldn't find a way of remotely debug the clases loaded on the PSQL DBMS.
Is this possible to achieve?
Thanks in advance!
I suppose you could set pljava.vmoptions to enable debugging and include a port number to listen on, and then use Eclipse's "debug remote application" launcher to connect to it.
So a JVM option -agentlib:jdwp=transport=dt_socket,suspend=n,address=localhost:55000 will make the JVM listen on port 55000 for debuggers. You then open the "Debug configurations.." dialogue in Eclipse, right click "Remote Java Application" in the launch types pane on the left and update the connection properties on the right to use port 55000. You should connect up the debug launcher with a project as well, to pick up that project's class path and sources.
Note I haven't actually tried this in postgresql, but this corresponds to how I always used to run JBoss from a shell script rather than from within Eclipse.
I needed a slight change to the option line. The working one is-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:8000. Without the server=y part, the debugger complains about missing transport. With the above, everything worked.

Remote debug Jetty (no mvn, no plugins)

Past scenario
- Work with Tomcat and start in debug mode and Remote Debug with Eclipse.
- Define a port and connect with eclipse in this debug/remote port.
- Use to debug servers in other hosts/servers
Today scenario
Now, I'm using Jetty and I've try to do the same, but with no success, could anyone help-me with that?
I did not use Maven, and did not want to start Jetty inside from my Eclipse.
Environment:
Windows XP
Java V. 5
Jetty V. 6.1.15
Links:
http:// docs.codehaus.org/display/JETTY/Debugging
This did not help me!
http:// docs.codehaus.org/display/JETTY/Debugging+Jetty+with+Eclipse
http:// neelzone.wordpress.com/2007/06/18/jetty-and-eclipse-integration
These are to start inside Eclipse
This is what we are adding to our JBoss command line while development:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
Then we launch the eclipse remote debugging and connection to this port.
Update:
To run from jar (standalone) do the following
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8585,server=y,suspend=n -jar start.jar
For remote debugging you should use JPDA. There's a sort of tutorialish article about it available here.
In short, start your JVM with the argument:
-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n
and you are able to connect to the underlying JVM listening on port 8000 via the standard Eclipse debugger.
If you will use mvn jetty:run one day, you have to
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
appending -Xdebug ... doesn't works
Using the JVM "agentlib" command-line parameter before "start.jar" did not work for me, but this does:
How to allow Eclipse to remotely debug #Jetty (#JPDA #agentlib:jdwp) on port 8000
You have to create a file, $JETTY_BASE/start.ini (do not change $JETTY_HOME/start.ini) and put the following two lines in it:
--exec
-agentlib:jdwp=transport=dt_socket,address=localhost:8000,server=y,suspend=n