pentaho/pentaho-kettle · error · KettleException

Error initializing JNDI

Error message

Error initializing JNDI

What it means

initJNDI throws KettleException when it cannot determine the JNDI root directory: the given path is empty and resolving the relative path 'simple-jndi' via File.getCanonicalPath() fails (IOException). This initialization is required before looking up datasources via JNDI.

Solutions

  1. Pass an explicit, existing directory path to initJNDI instead of relying on the default 'simple-jndi' relative path
  2. Ensure the process working directory contains the simple-jndi directory and is readable
  3. Set the JNDI directory system/environment configuration (Const.JNDI_DIRECTORY) before initialization
  4. Verify file permissions on the working directory (chmod) or launch from a valid directory

Example fix

// before
JndiUtil.initJNDI("");
// after
JndiUtil.initJNDI("/opt/pentaho/simple-jndi");
Defensive patterns

Strategy: validation

Validate before calling

File jndiDir = new File(jndiPath == null || jndiPath.isEmpty() ? "simple-jndi" : jndiPath);
if (!jndiDir.exists() || !jndiDir.canRead()) {
  throw new IllegalStateException("JNDI directory missing or unreadable: " + jndiDir.getAbsolutePath());
}

Try / catch

try {
  JndiUtil.initJNDI(path);
} catch (KettleException e) {
  throw new IllegalStateException("JNDI init failed; check working dir / simple-jndi folder", e);
}

Prevention

When it happens

Trigger: Calling JndiUtil.initJNDI() with a null/empty path while the process working directory is unreadable/deleted, or getCanonicalPath() throws due to an I/O error resolving 'simple-jndi'.

Common situations: Running a transformation from a deleted or permission-restricted working directory, embedding Pentaho in an app server where CWD is not the PDI root so 'simple-jndi' cannot be resolved, containerizing Kettle without setting KETTLE_JNDI_DIRECTORY / Const.JNDI_DIRECTORY.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/71c6a1dd8e45374b. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/JndiUtil.java:31


package org.pentaho.di.core;

import java.io.File;

import org.pentaho.di.core.exception.KettleException;

public class JndiUtil {

  public static void initJNDI() throws KettleException {
    String path = Const.JNDI_DIRECTORY;

    if ( path == null || path.equals( "" ) ) {
      try {
        File file = new File( "simple-jndi" );
        path = file.getCanonicalPath();
      } catch ( Exception e ) {
        throw new KettleException( "Error initializing JNDI", e );
      }
      Const.JNDI_DIRECTORY = path;
    }

    System.setProperty( "java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory" );
    System.setProperty( "org.osjava.sj.root", path );
    System.setProperty( "org.osjava.sj.delimiter", "/" );
  }

}

View on GitHub (pinned to f3058517a1)