Using JNDI connection for Mondrian 4 in Pentaho BA Server

Context

In Mondrian 4 in Pentaho BA Server I explained how to create a datasource on top of Mondrian 4 Schema in the BA Server and later how to use it in Analyzer to create a basic report. The problem I could not overcome for a long time was how use a JNDI connection defined in tomcat inside a datasource definition. Luckily thanks to help given on Pentaho Forum I was finally able to solve the mystery.

This solution was tested with Pentaho BA Server 5.2.

Problem

To define a datasource that uses a JNDI connection we need to slightly modify olap4j.properties file located under ../pentaho/server/biserver-ee/pentaho-solutions/system. As opposed to the configuration from the previous article we do not provide connection details, but a name of JNDI connection defined in tomcat.

As a result, we will get a mysterious error saying that class PentahoDataSourceResolver cannot be found – java.lang.ClassNotFoundException: org.pentaho.platform.web.servlet.PentahoDataSourceResolver.

JNDI connection configuration

You might be wondering where to find the JNDI connections configuration file. It’s located under following location: ../pentaho/server/biserver-ee/tomcat/conf/Catalina/localhost/ pentaho.xml. Mine looks as follows:

Solution

The solution is extremely easy, we need to make sure that class PentahoDataSourceResolver is indeed visible when establishing the connection to the database. In order to do so we need to modify jar with mondrian implementation inside osgi bundles. In my case the file was named mondrian-4.1.0.0-209.jar and located under ../pentaho/server/biserver-ee/pentaho-solutions/system/osgi/bundles/.

We need to modify MANIFEST.MF file, particularly a line starting with Import-Package:, so that it look like this:

I would recommend removing all directories under ../pentaho/server/biserver-ee/pentaho-solutions/system/osgi/cache to make sure that after we restart our server OSGI will use a mondrian jar with modified MANIFEST file.

Sources and links

One thought on “Using JNDI connection for Mondrian 4 in Pentaho BA Server”

Please join discussion