Hitachi Vantara Pentaho Community Wiki
Child pages
  • 07. Debugging with the Standalone Platform Project
Skip to end of metadata
Go to start of metadata

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:

  1. Setting up the standalone project;
  2. Explain the code and resources that make the standalone configuration work;
  3. 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:

  1. 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.
  2. Right-click the build.xml file, and choose the 'Run As...' option, then the 'Ant Build...' option.
  3. You will be prompted with an Ant Build dialog. De-select any pre-selected targets, and select ONLY the sample-setup target.
  4. 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". 
  5. 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 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.

public static void main(String[] args) {
    try {
        SimpleCase sCase = new SimpleCase();
   	sCase.simpleCase( args );
    } catch (Exception e) {


public void simpleHelloWorldCase( String outputPath ) {
    try {
        File f = new File( outputPath + File.separator + "hello_world.txt" );
        FileOutputStream outputStream = new FileOutputStream(f);
        HashMap parameters = new HashMap();
        ISolutionEngine solutionEngine = SolutionHelper.execute( "Simple Case Example", "Hello World",
                                       "getting-started/HelloWorld.xaction", parameters, outputStream );

    } catch (Exception e) {

The class has only one interesting method - the method that initializes the platform:

public static boolean initialize() {
    try {
        // We need to be able to locate the solution files. in this example, we are using the relative path in our project/package.
        File solutionRoot = new File( "resource/solution" );

        // Create a standalone application context - our application toolbox if you will - passing the path to the solution files.
        IApplicationContext context = new StandaloneApplicationContext(solutionRoot.getAbsolutePath(), new File(".").getAbsolutePath());

        // Initialize the Pentaho system
        PentahoSystem.init( context );

        return true;

    } catch (Throwable t) {
        return false;

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:

  1. Navigate to the pentaho-data folder, either via command line or using your favorite file explorer tool - outside of Eclipse.
  2. 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/, and open that file.

3.  Place a breakpoint (from the right-click menu) on line 73 in the file (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 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

  • No labels