Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug Playframework in Eclipse

I just moved from Netbeans to Eclipse. In Netbeans, I can debug Playframework applications out of the box. However, in Eclipse, it seems hard to configure this in order to debug a web app (a Playframework app in specific).

As in Play! documentation,

The main launcher in only usable with the Run As eclipse command. You can then use the “Connect JPDA launcher” using “Debug As” to start a debugging session at any time. Stopping the debugging session will not stop the server.

However, I can not see “Connect JPDA launcher” in "Debug As" (I'm using Eclipse Classic 3.7.0). I've searched about JPDA (I'm new to Java and don't know about "main launcher" and JPDA, then config Remote Debug as instruct in http://javarevisited.blogspot.com/2011/02/how-to-setup-remote-debugging-in.html But it's returning an error:

Failed to connect to remote VM. Connection refused. Connection refused: connect

I've searched and found some suggestions like:

1.)editing catalina.bat and adding the lines : set JPDA_TRANSPORT=dt_socket ... set JPDA_ADDRESS=8000 AND 2.)Editing startup.bat call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

Actually I don't clearly understand this and I guess it's for configuring Tomcat. However, I'm using Play! default server, checked the application.conf and sure that it's listening to port 9000 and 8000 for JPDA.

Of course, I have started the Play app before debugging, I can access the app via port 9000 normally. I'm using Win 7 with no admin rights.

Do you have a detailed guide on debugging Play! in Eclipse?

like image 468
Thang Nguyen Avatar asked Aug 24 '11 07:08

Thang Nguyen


People also ask

How do I debug a breakpoint in Eclipse?

To put breakpoints in your code, double click in the left margin on the line you want execution to stop on. You may alternatively put your cursor in this line and then press Shift + Ctrl + B . To control execution use the Step Into, Step Over and Step Return buttons. They have the shortcuts F5 , F6 and F7 respectively.

How do I get debug view in Eclipse?

First, we need to start the Java program within Eclipse in debug mode. This can be achieved in two ways: Right-click on the editor and select Debug As -> Java Application (shown in below screenshot) Debug the program from the toolbar (highlighted in below screenshot)


1 Answers

As of Play 2.0, the eclipse folder and launchers are no longer generated when you run play eclipsify. After running play eclipsify, you can debug your project in Eclipse as follows:

  1. In a console outside of eclipse, run play debug run.
  2. In Eclipse, right-click your project, then choose Debug As -> Debug Configurations...
  3. Right-click Remote Java Application, then click New.
  4. The host should already be set to localhost. Set the port to 9999 (the default port used by the play debug run command).
  5. Click Apply to save, then Debug to connect to your running Play instance.
like image 149
Mansoor Siddiqui Avatar answered Oct 02 '22 13:10

Mansoor Siddiqui