quarkusio/quarkus · error · IllegalStateException
No template resource path specified
Error message
No template resource path specified
What it means
The mailer's CDI producer creates a MailTemplate for an injection point based on the @Location qualifier value, which names the template resource path. If the injection point has no @Location qualifier or the value is empty, the producer cannot resolve a template and throws this IllegalStateException at bean creation time.
Source
Thrown at extensions/mailer/runtime/src/main/java/io/quarkus/mailer/runtime/MailTemplateProducer.java:71
return new MailTemplateInstanceImpl(getReactiveMailer(injectionPoint, reactiveMailer),
template.select(new LocationLiteral(name)).get().instance());
}
};
}
@Location("ignored")
@Produces
MailTemplate get(InjectionPoint injectionPoint, @Any Instance<ReactiveMailer> reactiveMailer) {
Location path = null;
for (Annotation qualifier : injectionPoint.getQualifiers()) {
if (qualifier.annotationType().equals(Location.class)) {
path = (Location) qualifier;
break;
}
}
if (path == null || path.value().isEmpty()) {
throw new IllegalStateException("No template resource path specified");
}
final String name = path.value();
return new MailTemplate() {
@Override
public MailTemplateInstance instance() {
return new MailTemplateInstanceImpl(getReactiveMailer(injectionPoint, reactiveMailer),
template.select(new LocationLiteral(name)).get().instance());
}
};
}
static ReactiveMailer getReactiveMailer(InjectionPoint injectionPoint, Instance<ReactiveMailer> reactiveMailer) {
MailTemplateMailerName mailerName = injectionPoint.getAnnotated().getAnnotation(MailTemplateMailerName.class);
if (mailerName != null) {
return reactiveMailer.select(MailerName.Literal.of(mailerName.value())).get();
}
return reactiveMailer.select(Default.Literal.INSTANCE).get();
}View on GitHub (pinned to e1c734241f)
Solutions
- Annotate the injection point with the template resource path: @Inject @Location("mails/welcome") MailTemplate welcome;
- Make sure the @Location value is non-empty and matches a file under src/main/resources/templates.
- For multiple named templates in one class, use distinct fields each with its own @Location rather than one unqualified injection.
Example fix
// before
@Inject
MailTemplate mailTemplate;
// after
@Inject
@Location("mails/welcome")
MailTemplate mailTemplate; Defensive patterns
Strategy: validation
Validate before calling
// Compile-time: every MailTemplate injection point must carry @Location
@Inject @Location("mails/welcome") MailTemplate welcome; // correct pattern Prevention
- Treat @Location as mandatory on every MailTemplate injection point
- Search the codebase for 'MailTemplate' injections missing @Location during code review
- Keep template paths as constants so typos fail at compile time
When it happens
Trigger: Injecting MailTemplate without @Location (e.g. plain @Inject MailTemplate tpl;) or with an empty @Location("") — the producer's get(InjectionPoint, Instance<ReactiveMailer>) method rejects it immediately.
Common situations: Forgetting the @Location annotation when adding a mail template injection; refactoring and accidentally emptying the annotation value; programmatic lookup of MailTemplate beans without any Location qualifier.
Related errors
- No template variant found
- Dev services for ${request.getName()} requires a startable s
- Multiple @Inject constructors on ${theClass}
- Quarkus does not support CDI Full @Specializes annotation; t
- IllegalStateException wrapping ClassNotFoundException for ge
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/c2a7a477934b7437.
Report an issue: GitHub.