{"record":{"id":"8a59004d2071b822","repo":"quarkusio/quarkus","slug":"cache-region-cachename-weigher-class-requi","errorCode":null,"errorMessage":"Cache region '${cacheName}': 'weigher-class' requires 'maximum-weight' to be set.","messagePattern":"Cache region '(.+?)': 'weigher-class' requires 'maximum-weight' to be set\\.","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/util/HibernateProcessorSupport.java","lineNumber":431,"sourceCode":"        }\n    }\n\n    private static QuarkusPersistenceUnitCacheConfiguration toQuarkusCacheConfiguration(\n            HibernateOrmConfigPersistenceUnit config) {\n        Map<String, QuarkusPersistenceUnitCacheConfiguration.Cache> caches = new HashMap<>();\n        for (var regionEntry : config.cache().entrySet()) {\n            String cacheName = regionEntry.getKey();\n            var cacheConfig = regionEntry.getValue();\n            var memory = cacheConfig.memory();\n\n            // Validate mutual exclusivity\n            if (memory.objectCount().isPresent() && memory.maximumWeight().isPresent()) {\n                throw new IllegalStateException(\n                        \"Cache region '\" + cacheName + \"': 'object-count' and 'maximum-weight' are mutually exclusive. \"\n                                + \"Use 'object-count' for count-based eviction or 'maximum-weight' for weight-based eviction.\");\n            }\n            if (memory.weigherClass().isPresent() && memory.maximumWeight().isEmpty()) {\n                throw new IllegalStateException(\n                        \"Cache region '\" + cacheName + \"': 'weigher-class' requires 'maximum-weight' to be set.\");\n            }\n\n            caches.put(cacheName, new QuarkusPersistenceUnitCacheConfiguration.Cache(\n                    memory.objectCount().orElse(QuarkusPersistenceUnitCacheConfiguration.Cache.DEFAULT.maxSize()),\n                    cacheConfig.expiration().maxIdle()\n                            .orElse(QuarkusPersistenceUnitCacheConfiguration.Cache.DEFAULT.maxIdle()),\n                    memory.maximumWeight().orElse(-1L),\n                    memory.weigherClass().orElse(null)));\n        }\n        return new QuarkusPersistenceUnitCacheConfiguration(caches);\n    }\n\n    private static void configureValidation(QuarkusPersistenceUnitDescriptor descriptor,\n            HibernateOrmConfigPersistenceUnit config) {\n        descriptor.getProperties().setProperty(\n                AvailableSettings.JAKARTA_VALIDATION_MODE,\n                config.validation().mode()","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/util/HibernateProcessorSupport.java#L413-L449","documentation":"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.","triggerScenarios":"toQuarkusCacheConfiguration encounters a region with quarkus.hibernate-orm.\"pu\".cache.\"<region>\".memory.weigher-class set while memory.maximum-weight is absent.","commonSituations":"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.","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"],"exampleFix":"// before\nquarkus.hibernate-orm.cache.\"com.acme.Foo\".memory.weigher-class=com.acme.FooWeigher\n// after\nquarkus.hibernate-orm.cache.\"com.acme.Foo\".memory.weigher-class=com.acme.FooWeigher\nquarkus.hibernate-orm.cache.\"com.acme.Foo\".memory.maximum-weight=100MB","handlingStrategy":"validation","validationCode":"// weigher-class only makes sense with maximum-weight\nif (props.containsKey(\"...memory.weigher-class\")\n && !props.containsKey(\"...memory.maximum-weight\"))\n    throw new IllegalStateException(\"weigher-class requires maximum-weight\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["quarkus","hibernate-orm","caching","weigher"],"backgroundTag":"incomplete-cache-configuration","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}