quarkusio/quarkus · error · java.lang.IllegalStateException

No template location specified

Error message

No template location specified

What it means

TemplateProducer.getTemplate(InjectionPoint) resolves the template path for an injected @Location-qualified template or a type-safe @CheckedTemplate. When a @Location annotation is required (non-type-safe injection) but no path can be determined, injection fails with this IllegalStateException at startup.

Source

Thrown at extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java:107

                name = injectionPoint.getMember().getName();
                LOGGER.warnf("Parameter name not present - using the method name as the template name instead %s", name);
            }
        }
        return newInjectableTemplate(name);
    }

    @Produces
    @Location("ignored")
    Template getTemplate(InjectionPoint injectionPoint) {
        String path = null;
        for (Annotation qualifier : injectionPoint.getQualifiers()) {
            if (qualifier.annotationType().equals(Location.class)) {
                path = ((Location) qualifier).value();
                break;
            }
        }
        if (path == null || path.isEmpty()) {
            throw new IllegalStateException("No template location specified");
        }
        return newInjectableTemplate(path);
    }

    /**
     * Used by NativeCheckedTemplateEnhancer to inject calls to this method in the native type-safe methods.
     */
    public Template getInjectableTemplate(String path) {
        return newInjectableTemplate(path);
    }

    public void clearInjectedTemplates() {
        if (injectedTemplates != null) {
            synchronized (injectedTemplates) {
                for (Iterator<WeakReference<InjectableTemplate>> it = injectedTemplates.iterator(); it.hasNext();) {
                    WeakReference<InjectableTemplate> ref = it.next();
                    InjectableTemplate template = ref.get();
                    if (template == null) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Annotate the injection point with @Location("path/to/template") matching a template under src/main/resources/templates.
  2. Use @CheckedTemplate static fields instead of raw Template injection to get generated locations.
  3. Verify you import io.quarkus.qute.Location (not a same-named annotation from another library).
  4. Inject a concrete generated template class instead of the generic Template type.

Example fix

// before
@Inject
Template page;
// after
@Inject
@Location("pages/page")
Template page;
Defensive patterns

Strategy: validation

Validate before calling

if (tpl.getClass().isAnnotationPresent(Location.class) == false && !inCheckedTemplate) {
    throw new IllegalArgumentException("Template injection needs @Location");
}

Type guard

boolean hasLocation(jakarta.enterprise.inject.spi.InjectionPoint ip) {
    return ip.getAnnotated().isAnnotationPresent(io.quarkus.qute.Location.class);
}

Try / catch

try { ctx.deploy(); } catch (IllegalStateException e) { if (e.getMessage().equals("No template location specified")) { /* add @Location or use @CheckedTemplate */ } else throw e; }

Prevention

When it happens

Trigger: Injecting a Template field/parameter with no @Location qualifier and no accompanying @CheckedTemplate-generated path, e.g. `@Inject Template tpl;` without any way to derive the location.

Common situations: Adding a Template injection point without @Location and outside a @CheckedTemplate class; removing a @Location annotation during refactoring; incorrect annotation import so the Location qualifier is not recognized.

Related errors


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