quarkusio/quarkus · error · IllegalStateException
Injected class not found in index:
Error message
Injected class not found in index:
What it means
The type of the @CachedResults injection point is not present in the deployment Jandex index. The build step must inspect the class (interface check, constructor check), so an unindexed type — typically from an external jar not indexed by Quarkus — fails the build.
Source
Thrown at extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CachedResultsProcessor.java:352
AnnotationValue excludeValue = annotation.value("exclude");
if (excludeValue != null)
exclude = excludeValue.asString();
if (annotation.target().kind() == Kind.FIELD) {
type = annotation.target().asField().type();
} else if (annotation.target().kind() == Kind.METHOD_PARAMETER) {
type = annotation.target().asMethodParameter().type();
} else {
throw new IllegalStateException("Unsupported target:" + annotation.target());
}
if (type.kind() != Type.Kind.CLASS) {
throw new IllegalStateException("Invalid type: " + type);
}
ClassInfo injectedClazz = index.getClassByName(type.name());
if (injectedClazz == null) {
throw new IllegalStateException("Injected class not found in index: " + type.name());
}
if (!injectedClazz.isInterface()
&& !injectedClazz.hasNoArgsConstructor()) {
throw new IllegalStateException(
"@CachedResults class must be an interface or declare a no-args constructor: " + injectedClazz);
}
return new CachedResultsInjectConfig(cacheName, lockTimeout, keyGenerator, injectedClazz,
// consider all but @CachedResults and @Inject
annotation.target().declaredAnnotations().stream().filter(
a -> !a.name().equals(CACHED_RESULTS)
&& !a.name().equals(INJECT))
.toList(),
exclude);
}
record CachedResultsInjectConfig(String cacheName, Long lockTimeout, DotName keyGenerator, ClassInfo injectedClazz,
Collection<AnnotationInstance> annotations, String exclude) {
View on GitHub (pinned to e1c734241f)
Solutions
- Add a META-INF/jandex.idx to the library jar, or depend on its `-jandex` classifier artifact if offered.
- If you control the jar, run the Jandex maven/gradle plugin on it.
- Ensure the class is actually on the application classpath and spelled correctly.
- For generated classes, make sure generation happens in a Quarkus-visible source root or via a build step that registers them in the index.
Example fix
<!-- before: external jar with no index --> <dependency> <groupId>com.example</groupId> <artifactId>my-api</artifactId> </dependency> <!-- after --> <dependency> <groupId>com.example</groupId> <artifactId>my-api</artifactId> <classifier>jandex</classifier> </dependency>
Defensive patterns
Strategy: validation
Validate before calling
// Check the type is on the classpath and indexed
Class<?> clazz = Class.forName("com.example.MyApi");
// If from a library, verify a jandex.idx exists:
// unzip -l my-api.jar | grep 'META-INF/jandex.idx' Prevention
- Prefer libraries that ship jandex indexes or use their -jandex classifier
- Keep cached interfaces in your own application sources when possible
- Confirm dependencies with a full ./mvnw build, not just IDE compilation
When it happens
Trigger: Injecting a type that lives in a dependency jar excluded from the application index (Jandex index), e.g. a class from a non-Quarkus library, or referencing a class produced outside the indexed sources.
Common situations: Third-party interfaces not annotated with @Indexable or shipped in jars without META-INF/jandex.idx; generated classes not visible to the deployment index; typos causing resolution of a non-existent class.
Related errors
- Invalid type:
- Unable to load the datasource driver <driverName> for the <f
- Unable to load the config property type: ${className}
- Unsupported target:
- @CachedResults class must be an interface or declare a no-ar
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/31ad99c5c70dd46b.
Report an issue: GitHub.