quarkusio/quarkus · warning · java.lang.IllegalStateException

Template source not available

Error message

Template source not available

What it means

In dev mode, QuteErrorPageSetup builds problem info for template exceptions by reading the template source. getBufferedReader throws this IllegalStateException when neither the on-disk source nor the captured generated content is available for the template id involved in the error — meaning the error page cannot show the template snippet.

Source

Thrown at extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/devmode/QuteErrorPageSetup.java:207

            // src/main/resources/templates
            Path templates = resource.resolve("templates");
            if (Files.exists(templates)) {
                // src/main/resources/templates/items.html
                Path template = templates.resolve(templateId.replace("\\", "/"));
                if (Files.exists(template)) {
                    return Files.newBufferedReader(template);
                }
            }
        }
        // Source file not available - try to search the generated contents
        Map<String, String> generatedContents = DevConsoleManager.getGlobal(GENERATED_CONTENTS);
        if (generatedContents != null) {
            String template = generatedContents.get(templateId);
            if (template != null) {
                return new BufferedReader(new StringReader(template));
            }
        }
        throw new IllegalStateException("Template source not available");
    }

    private Object getOrigin(Throwable t) {
        Object origin = null;
        try {
            Method getOrigin = t.getClass().getClassLoader().loadClass(TEMPLATE_EXCEPTION).getMethod("getOrigin");
            origin = getOrigin.invoke(t);
        } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException
                | IllegalArgumentException | InvocationTargetException e) {
            LOG.warn("Unable to read the origin field", e);
        }
        return origin;
    }

    private String getTemplateId(Object origin) {
        String templateId = null;
        try {
            Method getTemplateId = origin.getClass().getClassLoader().loadClass(ORIGIN).getMethod("getTemplateId");

View on GitHub (pinned to e1c734241f)

Solutions

  1. Refresh/restart dev mode (press 'r' or restart quarkus:dev) so sources and generated contents are back in sync.
  2. Restore the deleted/renamed template file referenced by the error.
  3. If the template is generated, ensure it is registered via the generated-contents mechanism (TemplateData/generated template APIs) rather than expected on disk.
  4. Check the actual template exception in the log — this error only obscures the source snippet, the root cause is the underlying template error.

Example fix

// before: template removed from src/main/resources/templates
// after: restore the file, e.g.
// src/main/resources/templates/page.html
Defensive patterns

Strategy: fallback

Validate before calling

if (!Files.exists(Path.of("src/main/resources/templates", templatePath))) {
    log.warn("Template source missing; error page snippet unavailable");
}

Try / catch

try { renderProblemInfo(t); } catch (IllegalStateException e) { if (e.getMessage().equals("Template source not available")) { showPlainErrorPage(t); } else throw e; }

Prevention

When it happens

Trigger: A template exception occurs in dev mode and the error page tries to load the source of a template that no longer exists on disk and is not in generatedContents (e.g. template generated in memory or deleted after compilation).

Common situations: Hot-reload race where a template is deleted/renamed while an error page renders; errors originating from programmatically generated templates (Strings/templates built at build time); stale browser page referencing a removed template.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/f101cd152a576d4c. Report an issue: GitHub.