pentaho/pentaho-kettle · error · IllegalArgumentException

Unsupported data source type: " + type

Error message

Unsupported data source type: " + type

What it means

getNamedDataSource throws IllegalArgumentException with 'Unsupported data source type: <type>' when the DatasourceType is null or not one of the handled cases (JNDI, POOLED). It is the default/exhaustive guard at the end of the switch.

Solutions

  1. Pass a valid DatasourceType (JNDI or POOLED) — check for null before the call.
  2. Fix whatever deserialization/config is producing a null or unknown type.
  3. If a new enum constant exists, extend the switch in the provider to handle it.
  4. Catch IllegalArgumentException and validate the type against DatasourceType.values() first.

Example fix

// before
DataSource ds = util.getNamedDataSource( config.getType(), name ); // getType() may be null
// after
DatasourceType t = config.getType();
if ( t == null ) { t = DatasourceType.JNDI; }
DataSource ds = util.getNamedDataSource( t, name );
Defensive patterns

Strategy: type-guard

Validate before calling

boolean isKnownType( DatasourceType t ) {
  return t != null && ( t == DatasourceType.JNDI || t == DatasourceType.POOLED );
}

Type guard

DatasourceType safeType( DatasourceType t ) {
  return t == null ? DatasourceType.JNDI : t;
}

Try / catch

try {
  ds = util.getNamedDataSource( type, name );
} catch ( IllegalArgumentException e ) {
  throw new IllegalStateException( "Bad datasource type in config: " + type, e );
}

Prevention

When it happens

Trigger: Calling getNamedDataSource with a null DatasourceType, or with an enum value added in a newer version of DatasourceType that this switch does not handle yet.

Common situations: Configuration deserialization producing a null type, API drift after adding a new DatasourceType constant, or passing the wrong enum between modules.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

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

    } finally {
      Thread.currentThread().setContextClassLoader( original );
    }

  }

  @Override
  public DataSource getNamedDataSource( String datasourceName, DatasourceType type )
    throws DataSourceNamingException {
    if ( type != null ) {
      switch ( type ) {
        case JNDI:
          return getNamedDataSource( datasourceName );
        case POOLED:
          throw new UnsupportedOperationException(
            getClass().getName() + " does not support providing pooled data sources" );
      }
    }
    throw new IllegalArgumentException( "Unsupported data source type: " + type );
  }

  @Override public DataSource invalidateNamedDataSource( String datasourceName, DatasourceType type )
    throws DataSourceNamingException {

    switch ( type ) {
      case POOLED:
        return ConnectionPoolUtil.removeDataSource( datasourceName );
      default:
        return FoundDS.remove( datasourceName );
    }
  }
}

View on GitHub (pinned to f3058517a1)