{"record":{"id":"f1ac2a13fa17221b","repo":"pentaho/pentaho-kettle","slug":"error-invoking-lifecycle-listener-0","errorCode":null,"errorMessage":"Error invoking lifecycle listener: {0}","messagePattern":"Error invoking lifecycle listener: (.+?)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/core/lifecycle/KettleLifecycleSupport.java","lineNumber":113,"sourceCode":"  public void onEnvironmentInit() throws KettleException {\n    // Execute only once\n    if ( initialized.compareAndSet( false, true ) ) {\n      for ( KettleLifecycleListener listener : kettleLifecycleListeners.keySet() ) {\n        onEnvironmentInit( listener );\n      }\n    }\n  }\n\n  private void onEnvironmentInit( KettleLifecycleListener listener ) throws KettleException {\n    // Run only once per listener\n    if ( kettleLifecycleListeners.replace( listener, false, true ) ) {\n      try {\n        listener.onEnvironmentInit();\n      } catch ( LifecycleException ex ) {\n        String message =\n          BaseMessages.getString( PKG, \"LifecycleSupport.ErrorInvokingKettleLifecycleListener\", listener );\n        if ( ex.isSevere() ) {\n          throw new KettleException( message, ex );\n        }\n        // Not a severe error so let's simply log it and continue invoking the others\n        LogChannel.GENERAL.logError( message, ex );\n      } catch ( Throwable t ) {\n        Throwables.propagateIfPossible( t, KettleException.class );\n        String message = BaseMessages.getString(\n          PKG, \"LifecycleSupport.ErrorInvokingKettleLifecycleListener\", listener );\n        throw new KettleException( message, t );\n      }\n    }\n  }\n\n  public void onEnvironmentShutdown() {\n    for ( KettleLifecycleListener listener : kettleLifecycleListeners.keySet() ) {\n      try {\n        listener.onEnvironmentShutdown();\n      } catch ( Throwable t ) {\n        // Log the error and continue invoking other listeners","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/core/lifecycle/KettleLifecycleSupport.java#L95-L131","documentation":"KettleLifecycleSupport.onEnvironmentInit() invokes each registered KettleLifecycleListener. A listener throwing a LifecycleException marked severe is wrapped into this KettleException with a localized 'Error invoking lifecycle listener: {0}' message. It means environment initialization was aborted by a plugin listener.","triggerScenarios":"Plugin registration adds a listener whose onEnvironmentInit() throws a severe LifecycleException during Kettle environment init (or later when a plugin is added at runtime).","commonSituations":"Lifecycle listeners validating environment (env vars, licenses, database availability) failing at startup; badly installed plugin.","solutions":["Read the wrapped LifecycleException cause to identify the failing listener and its complaint","Fix the environment condition the listener validates (missing env var, unreachable resource)","Uninstall/disable the offending plugin if unneeded","Log as non-severe by throwing LifecycleException with severe=false if failure is tolerable"],"exampleFix":"// before\nthrow new LifecycleException(true, \"db unreachable\"); // severe -> aborts init\n// after\nthrow new LifecycleException(false, \"db unreachable\"); // logged, init continues","handlingStrategy":"try-catch","validationCode":"// Pre-validate listener environment before KettleEnvironment.init()\nfor (KettleLifecycleListener l : ServiceLoader.load(KettleLifecycleListener.class)) {\n  try { l.onEnvironmentInit(); } catch (LifecycleException e) { preflightFailures.add(l + \": \" + e.getMessage()); }\n}","typeGuard":null,"tryCatchPattern":"try {\n  KettleEnvironment.init();\n} catch (KettleException e) {\n  if (e.getMessage().startsWith(\"Error invoking lifecycle listener\")) {\n    log.error(\"Plugin lifecycle listener failed init: \", e.getCause());\n  } else throw e;\n}","preventionTips":["Keep plugin lifecycle listeners dependency-light and side-effect-aware","Throw LifecycleException with severe=false for recoverable conditions","Remove stale plugins from the plugins directory"],"tags":["lifecycle","plugin","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}