Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Pentaho Java API

  1. #1

    Default Pentaho Java API

    I am brand new to Pentaho and have the task of trying to integrate it into some Java applications I have been working on. So far my experience with Pentaho includes downloading the community BI-Server and setting up a couple of things in the admin console (new users/datasources). I was able to get access to the datasource in my PUC as well for reports and analysis.
    Now I am trying to do practically the same thing in Java (Add a new datasource and configure it). I have been looking for different Java APIs and I must admit it is quite overwhelming with all the different APIs that are available (BI Platform, Kettle, Mondrian, Weka, Reporting). I decided to go with the BI Platform as this is the one that seems like it will fit this need. However the javadocs that are provided here seem to be out of date. I have imported the 4.8.0 dependency into my Java project via Maven and it seems I do not have some of the classes that are specified in the javadocs. Pentaho's APIs will probably begin to make more sense the more I dig into them, but as an overwhelmed n00b I need help in the following three ways.
    1) Is pentaho-bi-platform-api the correct API to connect to and administer datasources?
    2) Are there any useful java examples of the API that I could look at? (havent been able to find much on Google)

    3) Does anyone know if these javadocs are out of date and if so are there any more recent versions?

    I may just be looking in the wrong places so any help would be appreciated.

    Thanks a bunch

  2. #2
    Join Date
    May 2013


    Here's a link to the most basic method of launching transformations from Java:

    I have it working and passing parameter values from Java into the transformation pipeline. Now I'm trying to figure out how to do it asynchronously so the user doesn't have to wait for the transformation to complete.

    Good luck...

  3. #3


    I also realized I could get the source from and look at the UnitTests to get examples of how things should work. However I have run into an issue with the JndiDatasourceService.

    The following example can be found in the package org.pentaho.test.platform.repository.datasource in the bi-platform-repository project.

    public static final String SOLUTION_PATH = "test-src/solution";
                  private static final String ALT_SOLUTION_PATH = "test-src/solution";
                  private static final String PENTAHO_XML_PATH = "/system/pentaho.xml";
                  final String SYSTEM_FOLDER = "/system";
                  //      private static final String DEFAULT_SPRING_CONFIG_FILE_NAME = "pentahoObjects.spring.xml";
                  public String getSolutionPath() {
                          File file = new File(SOLUTION_PATH + PENTAHO_XML_PATH);
                          if(file.exists()) {
                                 System.out.println("File exist returning " + SOLUTION_PATH);
                     return SOLUTION_PATH;  
                          } else {
                                 System.out.println("File does not exist returning " + ALT_SOLUTION_PATH);      
                                 return ALT_SOLUTION_PATH;
                  public void testGetDatasource() throws DatasourceServiceException, SQLException {
                          Connection connection = null;
                          try {
                    JndiDatasourceService service = new JndiDatasourceService();
                                DataSource ds = service.getDataSource("SampleData");
                                assertNotNull( "DataSource is null", ds );
                                String dsBoundName = service.getDSBoundName("SampleData");
                                assertNotNull( "Bound name is null", dsBoundName );
                                String dsUnBoundName = service.getDSUnboundName("SampleData");
                                assertNotNull( "Unbound name is null", dsUnBoundName );
                         } finally {
                                if(connection != null) {
           public static void main(String[] args) throws DatasourceServiceException, SQLException {
                     JndiDatasourceServiceTest test = new JndiDatasourceServiceTest();
                     try {
                     } finally {
    But when I run this testGetDatasource() method I get a NullPointerException, which points back to the BaseDatasourceService

    // Security Helpers
      //TODO: clean this up so we don't have a fallback impl
      public static ICacheManager getCacheManager( IPentahoSession session ) {
        try {
        // TODO get the SimpleMapCacheManager into the object map somehow
            // we will try to use a simple map cache manager if one has not been configured
            ICacheManager cacheManager = pentahoObjectFactory.get(ICacheManager.class, session );
          return cacheManager;
        } catch (ObjectFactoryException e) {
            ICacheManager cacheManager = SimpleMapCacheManager.getInstance();
          Logger.warn( PentahoSystem.class.getName(), "Using default cache manager" ); //$NON-NLS-1$
          return cacheManager;
    The only thing I can think of is that the session is null? Anyone else ever have an issue with this?
    Last edited by and.decarlo; 06-18-2013 at 02:08 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.