{"record":{"id":"ad4d6c27bf2108fc","repo":"quarkusio/quarkus","slug":"engine-not-set","errorCode":null,"errorMessage":"Engine not set","messagePattern":"Engine not set","errorType":"exception","errorClass":"TemplateException","httpStatus":null,"severity":"error","filePath":"independent-projects/qute/core/src/main/java/io/quarkus/qute/FragmentNamespaceResolver.java","lineNumber":58,"sourceCode":"        this.priority = priority;\n    }\n\n    @Override\n    public void engineBuilt(Engine engine) {\n        this.engine = engine;\n    }\n\n    @Override\n    public CompletionStage<Object> resolve(EvalContext context) {\n        String id = context.getName();\n        Template template = null;\n        int idx = id.lastIndexOf('$');\n        if (idx != -1) {\n            // the part before the last occurrence of a dollar sign is the template identifier\n            String templateId = id.substring(0, idx);\n            Engine e = engine;\n            if (e == null) {\n                throw new TemplateException(\"Engine not set\");\n            }\n            template = e.getTemplate(templateId);\n            if (template == null) {\n                throw new TemplateException(\"Template not found: \" + templateId);\n            }\n            // the part after the last occurrence of a dollar sign is the fragment identifier\n            id = id.substring(idx + 1);\n        } else {\n            template = context.resolutionContext().getTemplate();\n        }\n        Fragment fragment = template.getFragment(id);\n        if (fragment != null) {\n            CompletableFuture<Object> ret = new CompletableFuture<>();\n            if (!context.getParams().isEmpty()) {\n                EvaluatedParams params = EvaluatedParams.evaluate(context);\n                params.stage.whenComplete((r, t) -> {\n                    if (t != null) {\n                        ret.completeExceptionally(t);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/qute/core/src/main/java/io/quarkus/qute/FragmentNamespaceResolver.java#L40-L76","documentation":"FragmentNamespaceResolver.resolve() parses ids of the form templateId$fragmentId and looks up the template through an Engine reference. If the engine field has not been initialized (e.g. the resolver was used outside a managed Quarkus/Qute setup), it throws TemplateException(\"Engine not set\").","triggerScenarios":"Resolving a {frag ...} / fragment namespace expression where the resolver's Engine reference was never injected or set — typically when the resolver is constructed manually in a plain Qute Engine setup or used before engine initialization.","commonSituations":"Unit tests constructing FragmentNamespaceResolver by hand without wiring the engine; using fragments outside the Quarkus Qute extension which normally injects the engine; engine closed or not yet started.","solutions":["Set the engine on the resolver (constructor/setter) before resolving fragment ids.","In plain Qute (non-Quarkus), use EngineBuilder to install the fragment namespace resolver with the engine instance.","In Quarkus, let the extension wire the resolver instead of instantiating it manually."],"exampleFix":"// before\nFragmentNamespaceResolver r = new FragmentNamespaceResolver();\n// engine never set -> TemplateException\n// after\nEngine engine = Engine.builder().addNamespaceResolver(...).build();\nFragmentNamespaceResolver r = new FragmentNamespaceResolver(engine); // engine wired","handlingStrategy":"validation","validationCode":"if (resolverEngine == null) {\n    throw new IllegalStateException(\"Wire FragmentNamespaceResolver with an Engine before resolving\");\n}","typeGuard":"boolean resolverReady(FragmentNamespaceResolver r) {\n    return r != null; // ensure constructed via path that injects the engine\n}","tryCatchPattern":"try {\n    return resolver.resolve(ctx);\n} catch (TemplateException ex) {\n    if (ex.getMessage().contains(\"Engine not set\")) {\n        throw new IllegalStateException(\"Resolver misconfigured: engine missing\", ex);\n    }\n    throw ex;\n}","preventionTips":["Let the Quarkus Qute extension inject/wire the resolver instead of constructing it manually","In plain Qute, register the resolver via EngineBuilder so it receives the engine","Write a startup smoke test that resolves one fragment id"],"tags":["qute","template","fragments","engine-not-set"],"backgroundTag":"dependency-not-initialized","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}