The Standalone project, pentaho-standalone, is an example application that harnesses the power of the platform WITHOUT a J2EE application server. The project contains a Java application that runs two action sequences, writing the results of each to a file.
In this section, we will walk through the following steps:
- Setting up the standalone project;
- Explain the code and resources that make the standalone configuration work;
- And finally, place a breakpoint in the sample code, to demonstrate debugging through the standalone application.
Standalone Project Setup
The Standalone project contains a dependency on the pentaho project. To get started with the Standalone project, you must first run an Ant target, sample-setup, that will populate the project with the appropriate libraries for our examples. To setup the Standalone Project:
- From the Java Perspective in Eclipse, select the build.xml file, located in the root of the pentaho-standalone project. I prefer the Navigator view for this (not visible by default), but there are several views that make file selection easy - use the one you like the most.
- Right-click the build.xml file, and choose the 'Run As...' option, then the 'Ant Build...' option.
- You will be prompted with an Ant Build dialog. De-select any pre-selected targets, and select ONLY the sample-setup target.
- Choose the 'Run' button at the bottom of the dialog. You should see the activity log from the script in the Console view in Eclipse. Once the target has completed, you will see the message "Build SUCCESSFUL".
- Select the root folder of the project, pentaho-standalone, in the Eclipse Navigator view. Right-click on the folder, and choose the 'Refresh' option. This will refresh the subfolders so that you can see the files added as a result of building the project.
The project should now be ready to step through, but let's first explain the files that make up the project.
The resource/solution Directory
The resource/solution directory holds the solution files for our example. These files are very similar to those that are included with our demo. There are two action sequences in our solution, 'Hello World' and 'Simple Report'. If you browse the resource/solution directory, you will see the files for the action sequences.
The Source Files
The src directory holds the source code for executing the platform as a standalone Java application. The org.pentaho.app.SimpleCase.java class is the main class that runs the platform, and ultimately our solution. This class initializes the platform, runs a very simple 'Hello World' action sequence, then runs a very simple JFreeReport action sequence. Both action sequences produce results that are written out to files for the sake of simplicity.
The org.pentaho.app.Init.java class has only one interesting method - the method that initializes the platform:
Stepping Through the Sample Code
Stepping through the code in Eclipse should be familiar to you, but we will provide an example here. Before you attempt to run the SimpleCase class in Eclipse, you must first start the demo databases. To start the databases:
- Navigate to the pentaho-data folder, either via command line or using your favorite file explorer tool - outside of Eclipse.
- Under the pentaho-data folder there are startup and shutdown scripts for both Windows OS and *nix platforms. Execute the start-up script that is appropriate for your computer (.bat files are for Windows, .sh files are for *nix).
Now let's set a breakpoint and execute the SimpleCase main() method , so that you can see the development process in action.
1. Start by switching to the Eclipse Debug Perspective, if you are not already there.
2. From one of Eclipse's many file exploring views ( I use Navigator), navigate in the pentaho-standalone project to src/org/pentaho/app/SimpleCase.java, and open that file.
3. Place a breakpoint (from the right-click menu) on line 73 in the file SimpleCase.java. (Note: as code changes this line number could and most likely will change. The line of code that we are breaking on is the line that contains the Init.initialize() code).
4. Right-click on the SimpleCase.java file in your file exploring view. Choose the 'Debug As...' option then the 'Java Application' option. This will launch the class as a Java application.
5. The program will stop execution at your breakpoint. From here, you can step into, step over or continue execution in Eclipse. Watch the Console view for additional debug messages.
Quick Links For This Document