{"record":{"id":"994ca932359d0b30","repo":"OpenAPITools/openapi-generator","slug":"couldn-t-load-template-engine-adapter-s-availabl","errorCode":null,"errorMessage":"Couldn't load template engine adapter %s. Available options: %n%s","messagePattern":"Couldn't load template engine adapter (.+?)\\. Available options: %n(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/TemplatingEngineLoader.java","lineNumber":45,"sourceCode":"    }\n\n    @SuppressWarnings(\"java:S112\") // ignore java:S112 as generic RuntimeException is acceptable here\n    public static TemplatingEngineAdapter byIdentifier(String id) {\n        ServiceLoader<TemplatingEngineAdapter> loader = ServiceLoader.load(TemplatingEngineAdapter.class, TemplatingEngineLoader.class.getClassLoader());\n\n        StringBuilder sb = new StringBuilder();\n        for (TemplatingEngineAdapter templatingEngineAdapter : loader) {\n            if (id.equals(templatingEngineAdapter.getIdentifier())) {\n                return templatingEngineAdapter;\n            }\n            sb.append(templatingEngineAdapter.getIdentifier()).append(\"\\n\");\n        }\n\n        try {\n            // Attempt to load skipping SPI\n            return (TemplatingEngineAdapter) Class.forName(id).getDeclaredConstructor().newInstance();\n        } catch (Exception e) {\n            throw new RuntimeException(String.format(Locale.ROOT, \"Couldn't load template engine adapter %s. Available options: %n%s\", id, sb), e);\n        }\n    }\n}\n","sourceCodeStart":27,"sourceCodeEnd":49,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/TemplatingEngineLoader.java#L27-L49","documentation":"TemplatingEngineLoader resolves a templating engine by id: it iterates ServiceLoader-registered TemplatingEngineAdapter instances (bundled: handlebars, mustache) and, failing a match, attempts Class.forName(id) as a fallback for user-supplied adapter classes. If neither works it throws RuntimeException listing the available engine ids. The id comes from the templating engine setting (CLI --templating-engine / GeneratorSettings / 'templatingEngine' additional property).","triggerScenarios":"--templating-engine handlebar (typo for handlebars); --templating-engine mustache on an installation where the mustache adapter module is absent; passing a fully-qualified custom adapter class name whose JAR is not on the classpath.","commonSituations":"Typos in CI generator invocations; custom templating adapters built against an older SPI not registered via META-INF/services; trimmed classpaths (gradle module-hell) dropping the adapter module.","solutions":["Use one of the ids printed in the message's 'Available options' list — typically 'handlebars' or 'mustache'.","For a custom adapter, give its fully qualified class name and ensure its JAR (with META-INF/services registration) is on the classpath.","Check for stray whitespace/case in the --templating-engine value.","Omit the option to use the generator's default engine."],"exampleFix":"# before\n--templating-engine handlebar\n# after\n--templating-engine handlebars","handlingStrategy":"validation","validationCode":"Set<String> KNOWN_ENGINES = Set.of(\"handlebars\", \"mustache\");\nif (!KNOWN_ENGINES.contains(engineId) && !isValidClassName(engineId)) {\n    throw new IllegalArgumentException(\"Unknown templating engine: \" + engineId + \"; valid: \" + KNOWN_ENGINES);\n}","typeGuard":null,"tryCatchPattern":"Catch RuntimeException at startup; if the message starts with \"Couldn't load template engine adapter\", print the embedded 'Available options' list to the operator.","preventionTips":["Default to omitting --templating-engine unless you need handlebars.","For custom adapters, register them via META-INF/services and integration-test the Class.forName path.","Pin generator versions so the engine id set is known."],"tags":["openapi","templating-engine","classpath","spi","configuration"],"backgroundTag":"templating-engine-not-found","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}