quarkusio/quarkus · error · IllegalArgumentException
Quarkus currently only supports using a single cache name. O
Error message
Quarkus currently only supports using a single cache name. Offending %s is %s
What it means
Spring allows @Cacheable(value = {"a", "b"}) to store results in several caches, but Quarkus's Spring Cache extension resolves exactly one cache name per annotation. SpringCacheUtil.singleName() reads the string-array value and throws if more than one name is supplied. This keeps the mapping to a single underlying Quarkus cache simple.
Source
Thrown at extensions/spring-cache/deployment/src/main/java/io/quarkus/spring/cache/SpringCacheUtil.java:42
if (cacheName == null || cacheName.isEmpty()) {
AnnotationValue value = annotationInstance.value();
if (value != null) {
cacheName = singleName(value, annotationInstance.target());
}
}
return (cacheName == null || cacheName.isEmpty()) ? Optional.empty() : Optional.of(cacheName);
}
private static String singleName(AnnotationValue annotationValue, AnnotationTarget target) {
if (annotationValue.kind() != AnnotationValue.Kind.ARRAY) { // shouldn't happen
return null;
}
String[] strings = annotationValue.asStringArray();
if (strings.length == 0) {
return null;
} else if (strings.length > 1) {
throw new IllegalArgumentException(
String.format("Quarkus currently only supports using a single cache name. Offending %s is %s",
target.kind() == AnnotationTarget.Kind.METHOD ? "method" : "class", target.toString()));
}
return strings[0];
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Reduce the annotation to a single cache name
- If several caches must be invalidated, add separate @CacheEvict annotations or use the native Quarkus @CacheInvalidateAll annotations (they compose)
- Declare the additional caches via application code instead of annotations
Example fix
// before
@CacheEvict({"items", "itemDetails"})
public void update(Item i) { ... }
// after
@CacheEvict("items")
public void update(Item i) { ... } Defensive patterns
Strategy: validation
Validate before calling
@Cacheable("items") // single name: OK
// @Cacheable({"a","b"}) // NOT supported
public Item find(long id) { ... } Prevention
- Always pass exactly one cache name
- Use multiple @CacheInvalidateAll/@CacheEvict-style annotations when multiple caches must be affected
- Keep a porting checklist when migrating from Spring
When it happens
Trigger: Annotating a method with multiple cache names, e.g. @Cacheable({"cache1", "cache2"}) or multiple values in @CacheEvict; getSpringCacheName() calls singleName() during deployment and fails.
Common situations: Porting Spring code that used multi-cache eviction to invalidate several caches at once; splitting entries across a primary and a near cache.
Related errors
- Currently Spring Cache annotations can only be added to meth
- Annotation '${instance}' on '${instance.target()}' contains
- Failed to open path tree with root %s
- Dev services for ${request.getName()} requires a startable s
- Name cannot start with '/':${name}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/7a33713b98a392b1.
Report an issue: GitHub.