Debug the Liferay plug-in Projects from Eclipse

Debug the Liferay plug-in Projects from Eclipse

In the part 4 of the series will see how to debug the Liferay Portlet from Eclipse. Most of the developers will like to step through the code
when the rendering or action happens.

Need some changes in Tomcat and Eclipse to enable debugging. This assumes the project is deployed as an exploded war file as in Part 3.

1. Tomcat Setup, Enable debugging in the Tomcat instance for Liferay.

NOTE: This step is required if you only if you are planning to start Liferay Tomcat from command prompt by running “startup.bat”. If tomcat is started from IDE skip this step.


a. Edit the setenv.bat file at: D:\liferay-portal-5.2.3\tomcat-6.0.18\bin .Add these lines after set JRE_HOME
set JPDA_ADDRESS=5005

set JPDA_TRANSPORT=dt_socket

b. Edit the startup.bat file and add “jpda” to the last line, the file is located at, D:\liferay-portal-5.2.3\tomcat-6.0.18\bin
Edit the line call "%EXECUTABLE%" start %CMD_LINE_ARGS% , Add jpda to that so that the modified script look like

call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

1. b. Modify VM arguments from Eclipse (If Liferay server is started from Eclipse IDE)

Double click on the server created, Click on “Open Configuration”, Select “Arguments” tab,


Add the following line to the “VM Arguments”

-Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n


2. Eclipse, Configure Debugger

1. Select the menu item Project -> Run->Debug Configurations
2. Click on Remote Java Application and select New

3. Name it like say, Liferay Debugger


4. Browse and pick your Project

5. Set the port to 5005
6. Click on the Source tab and select Add
7. Pick Java Projects and select your source project(s)



8. Click Apply and Debug to start the debugger.
9. From the Eclipse IDE, add break points to the source code.

See Part 1 (Start-Stop Liferay from Eclipse) , Part 2 (Develop Spring MVC Portlet), Part 3 (Deploy to Maven)

7 comments:

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

    :((

    ReplyDelete
  2. Is the server running with these two settings?set JPDA_ADDRESS=5005
    set JPDA_TRANSPORT=dt_socket

    ReplyDelete
    Replies
    1. Hi Chandra,
      where I have to set this settings?
      I have a same problem (Failed to connect)!!!
      Can you help me out?

      Delete
    2. Please note, the batch file name may different in latest lifer version. Basically you need to set this as environment variables and , use 'jpda' when you start server.

      a. Edit the setenv.bat file at: D:\liferay-portal-5.2.3\tomcat-6.0.18\bin .Add these lines after set JRE_HOME
      set JPDA_ADDRESS=5005
      set JPDA_TRANSPORT=dt_socket

      b. Edit the startup.bat file and add “jpda” to the last line, the file is located at, D:\liferay-portal-5.2.3\tomcat-6.0.18\bin
      Edit the line call "%EXECUTABLE%" start %CMD_LINE_ARGS% , Add jpda to that so that the modified script look like

      call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

      Delete
  3. Hi Sir,
    now i want to learn Struts2 portlets and i have to work on these framework.so please help me how to develop struts portlets step by step process
    send me ur valuable suggestions with links
    Hope you soon waitng to ur reply.

    ReplyDelete
  4. It is interesting to have so good experience with Pass4sure Cisco dumps. This compact PDF guide helped me prepare my course under expertly guidance. I found nothing difficult to understand while reading from Cisco questions and answers. I suggest all to visit Dumpspass4sure.

    ReplyDelete