How To Debug Liferay Server With Eclipse
How To Debug Liferay Server With Eclipse
This document describes the configuration of Eclipse 3.4.1 that will allow to start, stop and debug a Liferay server. We assume that Eclipse has been installed and that the WST and JavaEE developers tools are installed. This tutorial describes a developer setup and therefore we will use MySQL database, instead of the default Hypersonic database. Therefore you will need to have administrator access to a MySQL installation. For this installation you also need a suitable JDK (1.5 and upwards). The following software must be installed on your computer Eclipse with WST and JavaEE developers installation; we used version3.4.1 JDK, we used version 1.6.0_01 MySQL database server, we used MySQL 5.0
Setting up Eclipse
First we create a server configuration to start and stop the Liferay server from our Eclipse environment. For this we first create a new server configuration. Select FileNewOther and choose the Server entry from the dialog. See screen below.
In the Server wizard select Tomcat 5.5 Server and provide a suitable name for this server. See the screenshot below.
Press next and fill in the Tomcat installation directory which is in our case d:\bin\liferay. Make sure that you select a JDK as the JRE to use for the server.
Now press Finish. Next we need to configure the server. This can be done by opening the configuration file. To do this double click on the Liferay server in the Servers view. Change the Server location to the second option (Use Tomcat installation) and change the default deploy path to webapps. See screenshot below.
Save the modifications by clicking on the save icon (or Ctrl-S). Next we need to change the VM arguments. Click the Open launch configuration link and switch to the Arguments tab of the dialog.
Add the following parameters as first entries of the VM Arguments: -Xms128m -Xmx512m -XX:MaxPermSize=128m -Djava.io.tmpdir="D:\bin\liferay\temp" -Djava.security.auth.login.config="D:\bin\liferay\conf\jaas.config" -Dfile.encoding=UTF8 -Duser.timezone=GMT+1 Now the dialog should look something like this.
Press the Apply and OK buttons to apply the changes. If everything was configured correctly the Liferay can now be started and stopped from the server. Before you attempt this make sure you have stopped the Liferay server using the shutdown.bat in d:\bin\liferay\bin. Launch the server by pressing the start button ( should look similar to the screenshot below. ). The server should start and the output console
Installing Sources
We create a separate Eclipse project containing the sources of Liferay. This project will allow us to set specific breakpoints and it provides an easy way to lookup the source code of Lifeway when debugging. First download the Liferay Portal 5.1.2 Source from the Liferay download page at http://www.liferay.com/web/guest/downloads/additional. Unzip the source package at d:\bin\liferay-src (or to another location of your own choice). Next we create a new Eclipse Java project that references these source by clicking FileNewJava Project Give the new project a suitable name. Next select Create project from existing source and fill in the location of the source files, in our case d:\bin\liferay-src.
Press the Finish button. This can take a while as Eclipse starts building the project.
Eclipse now shows the source files. You now can proceed debugging the server.