Skip to main content
Pentaho Documentation

Define JNDI Connections for the BA Server

Instructions for adding JNDI vary depending on which web application server you are using.

Add Drivers

The BA Server needs the appropriate driver to connect to the database that stores your data. If needed, you can download drivers from your database vendor's website. The Supported Technologies section contains a list of drivers.

Once you have the correct driver, copy it to this directory for the BA Server: /pentaho/server/biserver-ee/tomcat/lib/.

There should be only one driver for your database in this directory. Ensure that there are no other versions of the same vendor's driver in this directory. If there are, back up the old driver files and remove them to avoid version conflicts. This is a concern when you are adding a driver for the same database type as your Pentaho BA repository. If you have any concerns about how to proceed, contact Pentaho support.

Driver for Microsoft SQL Server

If you are using a Microsoft SQL Server (MSSQL), you might need to use an alternative, non-vendor-supported driver called JTDS. Contact Pentaho support to ensure that you are adding the correct driver.

For Microsoft Windows, most JDBC drivers support Type 2 integrated authentication through the integratedSecurity connection string property. To use integrated authentication, copy the sqljdbc_auth.dll file to all machines and directories to which you copied the JDBC driver. You can find this file in this location.

<installation directory>\sqljdbc_<version>\<language>\auth\
If running: Use the sqljdbc_auth.dll file here:
64-bit JVM on a x64 processor x64 folder
64-bit JVM on an Itanium processor IA64 folder

Tomcat JNDI Connections

  1. Stop the Tomcat and BA servers.
  2. Consult your database documentation to determine the class name and connection string for your database.
  3. Edit the /tomcat/webapps/pentaho/WEB-INF/web.xml file.
  4. At the end of the <web-app> element, in the same part of the file where you see <!-- insert additional resource-refs -->, add this XML snippet.
<resource-ref>
    <description>myDataSource</description>
    <res-ref-name>jdbc/myDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

Change the description and res-ref-name nodes, as well as any others that apply to your situation and fit your database. You may need to consult the JNDI Resources article in the Apache Tomcat documentation to see if there are other things to consider.

  1. Save and close the web.xml file.
  2. Edit the /tomcat/conf/context.xml with a text editor. Alternatively, you can modify the /tomcat/webapps/pentaho/META-INF/context.xml file if you want this data connection to be available only to the BA Server. Adding JNDI connections to the context.xml makes them available to all of the webapps deployed to this Tomcat instance.
  3. Anywhere inside of the Context element, add this XML snippet. Then save and close the context.xml file.
<Resource name="jdbc/myDataSource" 
    auth="Container" type="javax.sql.DataSource"
    factory="org.apache.commons.dbcp.BasicDataSourceFactory" 
    maxActive="20" 
    maxIdle="5"
    maxWait="10000" 
    username="dbuser" 
    password="password" 
    driverClassName="org.postgresql.Driver"
    url="jdbc:postgresql://127.0.0.1:5432/myDataSource"
/>   

This example shows a simple PostgreSQL configuration. Replace the Resource name, username, password, driverClassName, and url parameters, or any relevant connection settings, to match your database connection information and the details you supplied in the web.xml file earlier.

  1. Delete the pentaho.xml filed located in the /tomcat/conf/catalina/directory. The pentaho.xml is a cached copy of the context.xml file you modified. Since the cache is not usually configured to update frequently, you have to delete the pentaho.xml file and let Tomcat recreate it when it starts up.
  2. Start the Tomcat and BA Server.

Tomcat can now properly connect to your data. Please go on to the next stop on the Guide Post graphic.

Install JDBC Driver as a Module in JBoss

In JBoss, JDBC driver information is stored in a module, which is an XML file that you create. You must download the JDBC driver software component to the correct directory, then create module.xml files for each database.

The JDBC Drivers Reference has a list of supported drivers.

Create Module File for BA Repository Database

You need to create a file for the database that hosts the BA Repository (either PostgreSQL, MySQL, or Oracle), as well as for HSQLDB.

  1. Locate the pentaho/server/biserver-ee/<your jboss installation directory>/modules/system/layers/base/org folder and create one of the following paths for the database on which you are hosting the BA Repository.
    • PostgreSQL: postgresql/main
    • MySQL: mysql/main
    • Oracle: oracle/main
    • MS SQL Server: sqlserver/main
  2. Create these two paths in the same directory.
    • HSQLDB: hsqldb/main
    • H2: h2/main
  3. Download the supported JDBC driver for your BA Repository database to the directory that you just created. The JDBC Drivers Reference has a list of supported drivers
  4. Within that directory, do the following things:
    1. Use an editor to create a text file named module.xml.
    2. Copy the appropriate code into the module.xml file, then modify it so that the name of the JDBC driver you just downloaded appears.
    3. Save and close the module.xml file.
Repository Type Module code
PostgreSQL
<?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="org.postgresql">
        <resources>
            <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
        </resources>
        <dependencies><module name="javax.api"/></dependencies>
    </module>
MySQL
<?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="org.mysql">
        <resources>
            <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
        </resources>
        <dependencies><module name="javax.api"/></dependencies>
    </module>
Oracle
<?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="org.oracle">
        <resources>
            <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
        </resources>
        <dependencies><module name="javax.api"/></dependencies>
    </module>
MS SQL Server

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0"
name="org.sqlserver">
<resources>
<resource-root path="[Name of JDBC
Jar You Downloaded Here]"/>
</resources>
<dependencies><module name="javax.
api"/></dependencies>
</module>
 

Create Module File for HSQL Database

You will need to create a module file for the HSQL database.

The version of HSQLDB used should be 2.3.2.

  1. Download the supported JDBC driver for HSQLDB and place it in the hsqldb/main directory.
  2. In the hsqldb/main directory, create a text file named module.xml.
  3. Copy this code into the module.xml file, then modify it so that the name of the JDBC driver you just downloaded appears in the resource-root path.
    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="org.hsqldb">
    <resources>
    <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
    </resources>
    <dependencies><module name="javax.api"/></dependencies>
    </module>
    
  4. Save and close the module.xml file.

Create Module File for H2 Database

You need to create a module file for the H2 database.

  1. In the h2/main directory, create a text file named module.xml.
  2. Copy this code into the module.xml file, then modify it so that the name of the JDBC driver you just downloaded appears in the resource-root path.
    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="org.h2">
    <resources>
    <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
    </resources>
    <dependencies><module name="javax.api"/></dependencies>
    </module>
    
  3. Save and close the module.xml file.

Define JNDI Database Connection Information in JBoss

JNDI is used to specify port, driver, user name, and password information for the Audit and Quartz databases that are housed on your BA Repository database. This section shows you how to define your JNDI database connection information.

If you have a different database than PostgreSQL, or if you are using a different port, password, user, driver class information, or IP address, make sure that you adjust the examples in this section to match the ones in your environment.

  1. Copy the pentaho-style.war and pentaho.war files into the pentaho/server/biserver-ee/<your jboss installation directory>/standalone/deployment directory, or verify that the files are already there, as in PostgreSQL.
  2. Locate the pentaho/server/biserver-ee/<your jboss installation directory>/standalone/configuration/standalone.xml file and open it with a text editor.
  3. Insert these lines after the definition for ExampleDS data source.
                    <datasource jndi-name="java:jboss/datasources/Hibernate" pool-name="hibpool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                            <connection-url>
                                jdbc:postgresql://localhost:5432/hibernate
                            </connection-url>
                            <driver-class>
                                org.postgresql.Driver
                            </driver-class>
                            <driver>
                                org.postgresql
                            </driver>
                            <pool>
                                <prefill>
                                    false
                                </prefill>
                                <use-strict-min>
                                    false
                                </use-strict-min>
                                <flush-strategy>
                                    FailingConnectionOnly
                                </flush-strategy>
                            </pool>
                            <security>
                                <user-name>
                                    hibuser
                                </user-name>
                                <password>
                                    password
                                </password>
                            </security>
                        </datasource>
                        <datasource jndi-name="java:jboss/datasources/Quartz" pool-name="quartzpool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                            <connection-url>
                                jdbc:postgresql://localhost:5432/quartz
                            </connection-url>
                            <driver-class>
                                org.postgresql.Driver
                            </driver-class>
                            <driver>
                                org.postgresql
                            </driver>
                            <pool>
                                <prefill>
                                    false
                                </prefill>
                                <use-strict-min>
                                    false
                                </use-strict-min>
                                <flush-strategy>
                                    FailingConnectionOnly
                                </flush-strategy>
                            </pool>
                            <security>
                                <user-name>
                                    pentaho_user
                                </user-name>
                                <password>
                                    password
                                </password>
                            </security>
                        </datasource>
                        <datasource jndi-name="java:jboss/datasources/Audit" pool-name="auditpool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                            <connection-url>
                                jdbc:postgresql://localhost:5432/hibernate
                            </connection-url>
                            <driver-class>
                                org.postgresql.Driver
                            </driver-class>
                            <driver>
                                org.postgresql
                            </driver>
                            <pool>
                                <prefill>
                                    false
                                </prefill>
                                <use-strict-min>
                                    false
                                </use-strict-min>
                                <flush-strategy>
                                    FailingConnectionOnly
                                </flush-strategy>
                            </pool>
                            <security>
                                <user-name>
                                    pentaho_user
                                </user-name>
                                <password>
                                    password
                                </password>
                            </security>
                        </datasource> 
                   
                        <datasource jndi-name="java:jboss/datasources/pentaho_operations_mart" pool-name="pentahooperationsmartpool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                             <connection-url>
                                 jdbc:postgresql://localhost:5432/hibernate
                             </connection-url>
                             <driver-class>
                            org.postgresql.Driver
                             </driver-class>
                             <driver>
                                 org.postgresql
                             </driver>
                             <pool>
                               <prefill>
                                false
                               </prefill>
                            <use-strict-min>
                                false
                            </use-strict-min>
                            <flush-strategy>
                                FailingConnectionOnly
                            </flush-strategy>
                        </pool>
                        <security>
                            <user-name>
                                hibuser
                            </user-name>
                            <password>
                                password
                            </password>
                        </security>
                    </datasource>
                        <datasource jndi-name="java:jboss/datasources/PDI_Operations_Mart" pool-name="PDI_Operations_Mart" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                             <connection-url>
                                  jdbc:postgresql://localhost:5432/hibernate
                             </connection-url>
    					     <driver-class>
    					     org.postgresql.Driver
    					     </driver-class>
    					     <driver>
    					          org.postgresql
    					     </driver>
    					     <pool>
    						     <prefill>false</prefill>
    						     <use-strict-min>false</use-strict-min>
    						     <flush-strategy>FailingConnectionOnly</flush-strategy>
    					     </pool>
    					     <security>
    						     <user-name>hibuser</user-name>
    						     <password>password</password>
    					     </security>
    				</datasource>                             
     
    
                      
  4. Add the driver definition in the driver section of the file. Here is an example of the PostgreSQL driver definition. If you are using another database, modify the driver name, module, and data source class accordingly.
    <driver name="org.postgresql" module="org.postgresql"> 
    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
    </driver> 
    <driver name="org.hsqldb" module="org.hsqldb"> 
    <driver-class>org.hsqldb.jdbcDriver</driver-class> 
    </driver>
  5. Save and close the standalone.xml file.

Remove JNDI Resource References in JBoss

Because JBoss has its own mechanism for referencing JNDI data sources, the resource-references in the web.xml file located in the pentaho.war are not needed. You must remove these resource-references for the BA Server to operate properly.

  1. Navigate to the pentaho/server/biserver-ee/<your jboss installation directory>/standalone/deployments directory.
  2. Use a zip extraction utility (such as 7-Zip, Winzip, or Archive) to view the contents of the pentaho.war file. Do not unzip or extract the contents of the file.
  3. Navigate to the WEB-INF directory and open the web.xml file in a text editor.
  4. Delete all <resource-ref> tagged entries including everything between the <resource-ref> and </resource ref> tags.
  5. Save and close the file.
  6. The zip extraction utility that you used might show a prompt that asks whether you would like to update the file in the pentaho.war archive. If this happens, confirm that you would like to do this.

Update JNDI Data Source Reference to Conform to JBoss Standards

Update these files so that referenced JNDI datasources conform to JBoss standards.

  1. Use a text editor to open the pentaho/server/biserver-ee/pentaho-solutions/system/quartz/quartz.properties file.
    1. Change the org.quartz.dataSource.myDS.jndiURL value to jboss/datasources/Quartz, then save and close the file.
  2. Use a text editor to open the pentaho/server/biserver-ee/pentaho-solutions/system/audit_sql.xml file.
    1. Change the JNDI value to jboss/datasources/Hibernate, then save and close the file.
  3. Use a text editor to open the pentaho/server/biserver-ee/pentaho-solutions/system/data-access/settings.xml file.
    1. Change the data-access-staging-jndi value to jboss/datasources/Hibernate, then save and close the file.
  4. Open the pentaho/server/biserver-ee/pentaho-solutions/system/audit/dialects/h2 directory. (Make sure you open the file from the correct folder.)
  5. Use the text editor to open each file in the H2 directory and make the following changes:
    1. Change <database>Audit</database> to <database>jboss/datasources/Audit</database>.
    2. Change <database>Hibernate</database> to <database>jboss/datasources/Hibernate</database>.