pentaho/pentaho-kettle · error · NamingException

DatabaseUtil.DSNotFound

DatabaseUtil.DSNotFound

Error message

DatabaseUtil.DSNotFound (localized, parameter: dsName)

What it means

DatabaseUtil.getDataSourceFromJndi throws a NamingException when the requested datasource name is empty, with a localized message keyed DatabaseUtil.DSNotFound that includes the dsName. This is a fast-fail guard before any JNDI lookup is attempted.

Solutions

  1. Provide a valid non-empty JNDI datasource name before calling the lookup.
  2. Check the database connection settings in Spoon/repository and set the JNDI name.
  3. Validate the configuration value that feeds dsName (property/env variable may be empty).
  4. Catch NamingException and surface a clear message naming the missing datasource.

Example fix

// before
DataSource ds = DatabaseUtil.getDataSourceFromJndi( cfg.getJndiName(), ctx ); // jndiName == ""
// after
if ( Utils.isEmpty( cfg.getJndiName() ) ) {
  throw new IllegalArgumentException( "JNDI datasource name must be set" );
}
DataSource ds = DatabaseUtil.getDataSourceFromJndi( cfg.getJndiName(), ctx );
Defensive patterns

Strategy: validation

Validate before calling

if ( dsName == null || dsName.trim().isEmpty() ) {
  throw new IllegalArgumentException( "JNDI datasource name must be provided" );
}
// then call DatabaseUtil.getDataSourceFromJndi(dsName, ctx)

Type guard

boolean hasJndiName( String s ) { return s != null && !s.trim().isEmpty(); }

Try / catch

try {
  ds = DatabaseUtil.getDataSourceFromJndi( dsName, ctx );
} catch ( NamingException e ) {
  if ( dsName == null || dsName.isEmpty() ) {
    throw new IllegalStateException( "Datasource name is empty; fix connection config", e );
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling getDataSourceFromJndi with a null or empty-string dsName (Utils.isEmpty check) while resolving a JNDI datasource against the given Context.

Common situations: Empty JNDI name in database connection metadata (e.g. a database connection saved without a datasource name), environment variables or properties that resolve to blank, or refactored code passing an unset variable.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/database/util/DatabaseUtil.java:63

  /**
   * Clears cache of DataSources (For Unit test)
   */
  protected static void clearDSCache() {
    FoundDS.clear();
  }

  /**
   * Since JNDI is supported different ways in different app servers, it's nearly impossible to have a ubiquitous way to
   * look up a datasource. This method is intended to hide all the lookups that may be required to find a jndi name.
   *
   * @param dsName The Datasource name
   * @return DataSource if there is one bound in JNDI
   * @throws NamingException
   */
  protected static DataSource getDataSourceFromJndi( String dsName, Context ctx ) throws NamingException {
    if ( Utils.isEmpty( dsName ) ) {
      throw new NamingException( BaseMessages.getString( PKG, "DatabaseUtil.DSNotFound", String.valueOf( dsName ) ) );
    }
    Object foundDs = FoundDS.get( dsName );
    if ( foundDs != null ) {
      return (DataSource) foundDs;
    }
    Object lkup = null;
    DataSource rtn = null;
    NamingException firstNe = null;
    // First, try what they ask for...
    try {
      lkup = ctx.lookup( dsName );
      if ( lkup instanceof DataSource ) {
        rtn = (DataSource) lkup;
        FoundDS.put( dsName, rtn );
        return rtn;
      }
    } catch ( NamingException ignored ) {
      firstNe = ignored;

View on GitHub (pinned to f3058517a1)