quarkusio/quarkus · error · IllegalStateException
Cache region '${cacheName}': 'weigher-class' requires 'maxim
Error message
Cache region '${cacheName}': 'weigher-class' requires 'maximum-weight' to be set. What it means
A cache region's weigher-class is only meaningful with weight-based eviction. HibernateProcessorSupport throws IllegalStateException when a weigher class is configured but maximum-weight is missing, because there is no weight bound to weigh against.
Source
Thrown at extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/util/HibernateProcessorSupport.java:431
}
}
private static QuarkusPersistenceUnitCacheConfiguration toQuarkusCacheConfiguration(
HibernateOrmConfigPersistenceUnit config) {
Map<String, QuarkusPersistenceUnitCacheConfiguration.Cache> caches = new HashMap<>();
for (var regionEntry : config.cache().entrySet()) {
String cacheName = regionEntry.getKey();
var cacheConfig = regionEntry.getValue();
var memory = cacheConfig.memory();
// Validate mutual exclusivity
if (memory.objectCount().isPresent() && memory.maximumWeight().isPresent()) {
throw new IllegalStateException(
"Cache region '" + cacheName + "': 'object-count' and 'maximum-weight' are mutually exclusive. "
+ "Use 'object-count' for count-based eviction or 'maximum-weight' for weight-based eviction.");
}
if (memory.weigherClass().isPresent() && memory.maximumWeight().isEmpty()) {
throw new IllegalStateException(
"Cache region '" + cacheName + "': 'weigher-class' requires 'maximum-weight' to be set.");
}
caches.put(cacheName, new QuarkusPersistenceUnitCacheConfiguration.Cache(
memory.objectCount().orElse(QuarkusPersistenceUnitCacheConfiguration.Cache.DEFAULT.maxSize()),
cacheConfig.expiration().maxIdle()
.orElse(QuarkusPersistenceUnitCacheConfiguration.Cache.DEFAULT.maxIdle()),
memory.maximumWeight().orElse(-1L),
memory.weigherClass().orElse(null)));
}
return new QuarkusPersistenceUnitCacheConfiguration(caches);
}
private static void configureValidation(QuarkusPersistenceUnitDescriptor descriptor,
HibernateOrmConfigPersistenceUnit config) {
descriptor.getProperties().setProperty(
AvailableSettings.JAKARTA_VALIDATION_MODE,
config.validation().mode()View on GitHub (pinned to e1c734241f)
Solutions
- Set memory.maximum-weight for the region alongside weigher-class
- Or remove weigher-class if you intend count-based eviction via object-count
- Confirm the weigher class implements the expected weigher interface and is on the classpath
Example fix
// before quarkus.hibernate-orm.cache."com.acme.Foo".memory.weigher-class=com.acme.FooWeigher // after quarkus.hibernate-orm.cache."com.acme.Foo".memory.weigher-class=com.acme.FooWeigher quarkus.hibernate-orm.cache."com.acme.Foo".memory.maximum-weight=100MB
Defensive patterns
Strategy: validation
Validate before calling
// weigher-class only makes sense with maximum-weight
if (props.containsKey("...memory.weigher-class")
&& !props.containsKey("...memory.maximum-weight"))
throw new IllegalStateException("weigher-class requires maximum-weight"); Prevention
- Always pair weigher-class with maximum-weight
- Don't mix count-based and weight-based config on the same region
- Validate application.properties cache sections in CI
When it happens
Trigger: toQuarkusCacheConfiguration encounters a region with quarkus.hibernate-orm."pu".cache."<region>".memory.weigher-class set while memory.maximum-weight is absent.
Common situations: Adding a custom weigher copied from Caffeine examples without setting the weight limit; partial migration from object-count to maximum-weight; misunderstanding that weigher alone enables weight-based eviction.
Related errors
- Cache region '${cacheName}': 'object-count' and 'maximum-wei
- Cannot find ORM mapping file '${mappingFileName}' in the cla
- Missing attribute '${nodeName}.class'
- Annotation ${dotName} was not expected on a target of kind $
- Type ${className} must be annotated with @Embeddable, becaus
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/8a59004d2071b822.
Report an issue: GitHub.