pentaho/pentaho-kettle · error · IllegalStateException

No job started for current Thread

Error message

No job started for current Thread

What it means

PurgeUtilityLogger stores per-thread PurgeUtilityLog state in a ThreadLocal. getPurgeUtilityLog() throws IllegalStateException "No job started for current Thread" when startJob() was never called on this thread (or its state was cleared by endJob), so log access is attempted without a started purge job. It's a state-machine error: logging calls are only valid between startJob and endJob on the same thread.

Solutions

  1. Call PurgeUtilityLogger.startJob(...) before any getLogger()/setCurrentFilePath()/endJob() usage on that thread.
  2. Ensure startJob and endJob are paired in a try/finally on the same thread.
  3. If work runs on worker threads, start a job (or propagate a shared log) inside each thread rather than relying on the initiating thread's ThreadLocal.
  4. Guard logging calls so they are skipped when no job is active.

Example fix

// before
PurgeUtilityLogger.endJob(); // throws if no job on this thread
// after
PurgeUtilityLogger.startJob( purgeJob );
try {
  // ... purge work & logging ...
} finally {
  PurgeUtilityLogger.endJob();
}
Defensive patterns

Strategy: validation

Validate before calling

if ( !jobStartedOnThisThread ) { PurgeUtilityLogger.startJob( job ); }

Type guard

boolean logAvailable() { try { /* invoke getPurgeUtilityLog */ return true; } catch ( IllegalStateException e ) { return false; } }

Try / catch

try { PurgeUtilityLogger.endJob(); } catch ( IllegalStateException e ) { /* no job on this thread: either startJob first or skip */ }

Prevention

When it happens

Trigger: Calling getLogger()/setCurrentFilePath()/endJob() (all of which call getPurgeUtilityLog) on a thread where startJob() was not invoked, after endJob() already cleared the ThreadLocal, or when work was handed to a different thread (executor/child thread) that never started the job.

Common situations: Purge utility logging invoked from an async task or worker thread different from the one that called startJob; double-calling endJob(); exception path skipping startJob() but later code still logging; reusing the logger across unrelated threads.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at plugins/pur/core/src/main/java/com/pentaho/di/purge/PurgeUtilityLogger.java:102

    getLogger().debug( s );
  }

  public void warn( String s ) {
    setCodeLine();
    getLogger().debug( s );
  }

  @Override
  public void error( Exception e ) {
    setCodeLine();
    getLogger().error( throwableToString( e ) );

  }

  private PurgeUtilityLog getPurgeUtilityLog() {
    PurgeUtilityLog currentLog = purgeUtilityLog.get();
    if ( currentLog == null ) {
      throw new IllegalStateException( "No job started for current Thread" );
    }
    return currentLog;
  }

  private Logger getLogger() {
    return (Logger) getPurgeUtilityLog().getLogger();
  }

  public boolean hasLogger() {
    return ( purgeUtilityLog.get() == null ) ? false : true;
  }

  @Override
  public void debug( Object arg0 ) {
    setCodeLine();
    getLogger().debug( arg0 );
  }

View on GitHub (pinned to f3058517a1)