{"record":{"id":"cf9be5ac14811514","repo":"pentaho/pentaho-kettle","slug":"metainjectmeta-exception-unabletoloadtransformationfromfile","errorCode":null,"errorMessage":"MetaInjectMeta.Exception.UnableToLoadTransformationFromFile","messagePattern":"MetaInjectMeta\\.Exception\\.UnableToLoadTransformationFromFile","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/meta-inject/impl/src/main/java/org/pentaho/di/trans/steps/metainject/MetaInjectMeta.java","lineNumber":562,"sourceCode":"                  String tmpFilename =\n                    realFilename.substring( realFilename.lastIndexOf( \"/\" ) + 1, realFilename.indexOf( \".\"\n                      + Const.STRING_TRANS_DEFAULT_EXT ) );\n                  String dirStr = realFilename.substring( 0, realFilename.lastIndexOf( \"/\" ) );\n                  RepositoryDirectoryInterface dir = rep.findDirectory( dirStr );\n                  mappingTransMeta = rep.loadTransformation( tmpFilename, dir, null, true, null );\n                } catch ( KettleException ke2 ) {\n                  // fall back to try loading from file system (transMeta is going to be null)\n                }\n              }\n            }\n          }\n          if ( mappingTransMeta == null ) {\n            mappingTransMeta = new TransMeta( bowl, realFilename, metaStore, rep, false, tmpSpace, null );\n            mappingTransMeta.getLogChannel().logDetailed( \"Loading Mapping from repository\",\n              \"Mapping transformation was loaded from XML file [\" + realFilename + \"]\" );\n          }\n        } catch ( Exception e ) {\n          throw new KettleException( BaseMessages.getString( PKG,\n            \"MetaInjectMeta.Exception.UnableToLoadTransformationFromFile\", realFilename ), e );\n        }\n        break;\n\n      case REPOSITORY_BY_NAME:\n        String realTransname = tmpSpace.environmentSubstitute( injectMeta.getTransName() );\n        String realDirectory = tmpSpace.environmentSubstitute( injectMeta.getDirectoryPath() );\n        if ( rep != null ) {\n          if ( !Utils.isEmpty( realTransname ) && !Utils.isEmpty( realDirectory ) && rep != null ) {\n            RepositoryDirectoryInterface repdir = rep.findDirectory( realDirectory );\n            if ( repdir != null ) {\n              try {\n                // reads the last revision in the repository...\n                //\n                // TODO: FIXME: see if we need to pass external MetaStore references to the repository?\n                //\n                mappingTransMeta = rep.loadTransformation( realTransname, repdir, null, true, null );\n","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/meta-inject/impl/src/main/java/org/pentaho/di/trans/steps/metainject/MetaInjectMeta.java#L544-L580","documentation":"During MetaInjectMeta's loadTransformation handling (specification method FILE), the mapping transformation is instantiated from a real filename via new TransMeta(...). Any failure reading/parsing that .ktr is wrapped in a KettleException using the localized message MetaInjectMeta.Exception.UnableToLoadTransformationFromFile with the filename. The injection transformation cannot resolve its target transformation.","triggerScenarios":"loadTransformation/MetaInjectMeta initialization with specificationMethod=FILENAME where realFilename points to a missing, unreadable, or malformed .ktr file, or variables (tmpSpace substitution) resolve to a wrong path.","commonSituations":"Moved/renamed transformation files; relative paths broken because the job runs from a different working directory; missing environment variables in the substitution space; permission issues on the file.","solutions":["Verify the file exists at the resolved path by logging the substituted realFilename.","Fix variable values (e.g. ${Internal.Transformation.Filename.Directory}) used in the filename.","Check file read permissions for the user running PDI.","Open the target .ktr in Spoon to confirm it is not corrupt."],"exampleFix":"// before: relative path that breaks at runtime\nString file = \"transforms/child.ktr\";\n// after: anchor to the transformation's own directory\nString file = \"${Internal.Transformation.Filename.Directory}/child.ktr\";","handlingStrategy":"validation","validationCode":"// Resolve and check the file before triggering the load\nString real = space.environmentSubstitute(injectMeta.getFileName());\nFile f = new File(real);\nif (!f.exists() || !f.canRead()) {\n  throw new IllegalStateException(\"Mapping transformation not readable: \" + real);\n}","typeGuard":null,"tryCatchPattern":"try {\n  loadMappingTransformation();\n} catch (KettleException e) {\n  logError(\"Could not load transformation from file \" + realFilename + \": \" + e.getCause(), e);\n}","preventionTips":["Use ${Internal.Transformation.Filename.Directory} for relative references","Verify file existence after variable substitution","Check OS-level read permissions for the PDI run user"],"tags":["file-not-found","kettle","meta-inject","transformation-loading"],"backgroundTag":"file-not-found","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"}