Debugging with Tomcat in Eclipse in 2.0
Now you will place a breakpoint in the platform Java code, run the 'Hello World' sample solution, and step through the code from that breakpoint.
Warning: Make sure you do not have another application using port 8080 on your computer; this is the default port for the Tomcat application server. While you can change the default port to something else, you do not want to unnecessarily complicate your installation because it makes it harder to test with later. If port 8080 is in use, temporarily shut down the application that is using it while you are running Tomcat.
These steps are for Eclipse version 3.3.1 - for other versions, the correct configuration may require different options
Configuring a Tomcat Server in Eclipse
- Checkout bi-platform-v2/trunk/* and mantle projects from svn://source.pentaho.org/svnroot/bi-platform-v2/trunk.
- Download and unzip Apache Tomcat 5.5 or greater.
- Download XMLTask, a third-party Ant task. If building from the command line, download the JAR and copy into <user.home>/.ant/lib. If building from Eclipse, download the JAR and add it to the classpath of the Ant plugin (Window > Preferences > Ant > Runtime > Classpath).
To configure a new Tomcat 5.5 server in the Eclispe IDE:
- Create dev_override.properties in the bi-platform-build directory.
- Add the property tomcat.dir and make the value the absolute path to your unzipped Tomcat installation.
- Run ant -f dev_build.xml dev-rebuild in the bi-platform-build directory.
- In Eclipse, go to the Window menu and click on Preferences.
- Open the Server item and click on Installed Runtimes selection.
- Click Add...
- In the New Server Runtime dialog, select Apache from the list and select the sub-item Apache Tomcat V5.5 and then click Next >
- On the Tomcat Server page of the dialog, set the Tomcat installation directory to be the tomcat directory under the tomcat-pci-test\biserver-ce directory (this is the directory gets created by the dev-rebuild and it is located inside your Eclipse workspace).
- Click Finish, then click OK in the Preferences dialogue.
- Open the Server window in Eclipse by going to the Window menu, then selecting Show View, then Other, then Server, then Servers.
- In the Server window, right-click and select New, then Server.
- In the New Server dialogue, make sure the following fields are set correctly:
- Server's host name is localhost.
- Server type has Tomcat v5.5 Server selected.
- Server runtime is Apache Tomcat v5.5 (or the name that was assigned in step 5 above).
- Click Finish to create the server.
- Double-click on the newly created server (in the Servers window) to open the properties for that server.
- In the Server Locations section of the properties, make sure the Use Tomcat installation (takes control of Tomcat installation) option is selected.
- Click on the link titled Open launch configuration in the General section.
- In the Arguments tab of the dialogue, add the following to the VM arguments text box:
- In the Source tab of the dialog, click Add..., then add all the bi-platform... projects, then click OK.
- Click OK to save the changes and close the Launch Configuration dialogue.
- Save and close the properties window.
- Make sure you have the proper database server started. (Out of the box, this configuration will work with the Hypersonic database which start script is located under tomcat-pci-test\biserver-ce\data in your Eclipse workspace).
- With the new server highlighted, click on the Debug button to start the server in Debug mode.
- Once the server is running, open the following URL in a browser: http://localhost:8080/pentaho.
Verify Debug Mode Works
To verify that the server is running in debug mode:
- Open the source file org.pentaho.platform.plugin.action.examples.HelloWorldComponent in the bi-platform-plugin project (actions sub-project).
- Set a breakpoint on the first line of the executeAction() method.
- In a Web browser, login to the Pentaho PCI.
- In the Solution Repository, navigate to and run the Hello World action by clicking Go, then Solutions, then Getting Started, then Hello World.
- The Eclipse IDE should indicate a breakpoint has been hit.
- If the following error and stack trace appear when the server is started:
Then it indicates a system parameter's default value will not work for the installed operating system. To correct this problem, the following system property should be set in the launch configuration of the server (the Argument tab's VM arguments edit box). Note that the directory specified (/tmp/ in this example) should be a temporary directory that currently exists on the system.