quarkus: [Quarkus Native] ClassNotFoundException: com.github.benmanes.caffeine.cache.SSSW
Describe the bug
Using the Cache API with caffeine
leads to the following exception when running Quarkus 2.16.0.Final
in native
mode:
2023-01-31 13:56:54,211 ERROR [io.qua.run.Application] (main) Failed to start application (with profile [prod]): java.lang.ClassNotFoundException: com.github.benmanes.caffeine.cache.SSSW
at java.base@17.0.5/java.lang.Class.forName(DynamicHub.java:1132)
at java.base@17.0.5/java.lang.Class.forName(DynamicHub.java:1105)
at com.github.benmanes.caffeine.cache.LocalCacheFactory.loadFactory(LocalCacheFactory.java:84)
at com.github.benmanes.caffeine.cache.LocalCacheFactory.newBoundedLocalCache(LocalCacheFactory.java:40)
at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalAsyncCache.<init>(BoundedLocalCache.java:4216)
at com.github.benmanes.caffeine.cache.Caffeine.buildAsync(Caffeine.java:1096)
at io.quarkus.cache.runtime.caffeine.CaffeineCacheImpl.<init>(CaffeineCacheImpl.java:71)
at io.quarkus.cache.runtime.caffeine.CaffeineCacheManagerBuilder$1.get(CaffeineCacheManagerBuilder.java:56)
at io.quarkus.cache.runtime.caffeine.CaffeineCacheManagerBuilder$1.get(CaffeineCacheManagerBuilder.java:34)
at io.quarkus.cache.CacheManager_7ace4235729bbc654ace276b403267860dc707de_Synthetic_Bean.createSynthetic(Unknown Source)
at io.quarkus.cache.CacheManager_7ace4235729bbc654ace276b403267860dc707de_Synthetic_Bean.create(Unknown Source)
at io.quarkus.cache.CacheManager_7ace4235729bbc654ace276b403267860dc707de_Synthetic_Bean.create(Unknown Source)
at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:113)
at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:37)
at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:34)
at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:34)
at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:21)
at io.quarkus.cache.CacheManager_7ace4235729bbc654ace276b403267860dc707de_Synthetic_ClientProxy.arc$delegate(Unknown Source)
at io.quarkus.cache.CacheManager_7ace4235729bbc654ace276b403267860dc707de_Synthetic_ClientProxy.getCacheNames(Unknown Source)
at io.quarkus.cache.runtime.CacheManagerInitializer.onStartup(CacheManagerInitializer.java:14)
at java.base@17.0.5/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.arc.impl.Reflections.invokeMethod(Reflections.java:170)
at io.quarkus.cache.runtime.CacheManagerInitializer_Observer_onStartup_8dc69ad76cf9cc31e6928ed65580a8d3fd18a734.notify(Unknown Source)
at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:328)
at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:310)
at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:78)
at io.quarkus.arc.runtime.ArcRecorder.fireLifecycleEvent(ArcRecorder.java:131)
at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:100)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy(Unknown Source)
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:108)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
Expected behavior
No response
Actual behavior
This issue is related to the native
mode only. The JVM
mode is working just fine.
It also looks like it’s just an issue with 2.16.0.Final
, with 2.15.3.Final
everything works as expected, even in the native
mode.
How to Reproduce?
- Define a
Quarkus 2.16.0.Final
dependency - Add the
@CacheResult
annotation to an interceptable method - Run your app in
native
mode
Output of uname -a
or ver
No response
Output of java -version
openjdk 17.0.2 2022-01-18
GraalVM version (if different from Java)
GraalVM 22.3.0 Java 17 CE
Quarkus version or git rev
Quarkus 2.16.0.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
mvn
Additional information
The native build is conducted with the help of quay.io/quarkus/ubi-quarkus-native-image:22.3-java17
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 25 (15 by maintainers)
Commits related to this issue
- feat: simple Maven reproducer for https://github.com/quarkusio/quarkus/issues/30744 — committed to chberger/quarkus-cache-issue by chberger a year ago
- Fix comment about Caffeine optimization Per Ben Manes request in #30744 — committed to gsmet/quarkus by gsmet a year ago
- Caffeine - Automatically register metrics cache impls if Micrometer is around Fixes #30744 — committed to gsmet/quarkus by gsmet a year ago
- Caffeine - Automatically register metrics cache impls if Micrometer is around Fixes #30744 — committed to gsmet/quarkus by gsmet a year ago
- Caffeine - Automatically register metrics cache impls if Micrometer is around Fixes #30744 — committed to gsmet/quarkus by gsmet a year ago
- Fix comment about Caffeine optimization Per Ben Manes request in #30744 (cherry picked from commit 32da1f14ee97be863bee3fc22edc2c4a25961a04) — committed to gsmet/quarkus by gsmet a year ago
- Caffeine - Automatically register metrics cache impls if Micrometer is around Fixes #30744 (cherry picked from commit 743d6d55c6ddbd1e185b3cfd899ca82ac1d2c5eb) — committed to gsmet/quarkus by gsmet a year ago
- Register additional cache implementations for reflection Trying to find a good compromise for #30744 — committed to gsmet/quarkus by gsmet a year ago
- Register additional cache implementations for reflection Trying to find a good compromise for #30744 (cherry picked from commit 8746898ebbf3861c7ab4b300a2ac91ee0d2ba09f) — committed to gsmet/quarkus by gsmet a year ago
- Register additional cache implementations for reflection Trying to find a good compromise for #30744 (cherry picked from commit 8746898ebbf3861c7ab4b300a2ac91ee0d2ba09f) — committed to gsmet/quarkus by gsmet a year ago
- Register additional cache implementations for reflection Trying to find a good compromise for #30744 (cherry picked from commit 8746898ebbf3861c7ab4b300a2ac91ee0d2ba09f) — committed to gsmet/quarkus by gsmet a year ago
- Register additional cache implementations for reflection Trying to find a good compromise for #30744 (cherry picked from commit 8746898ebbf3861c7ab4b300a2ac91ee0d2ba09f) — committed to gsmet/quarkus by gsmet a year ago
- Update all non-major dependencies (mulk/mulkcms2!18) This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [com.diffplug.spotless:spotless-maven-plugin](ht... — committed to benkard/mulkcms2 by benkard a year ago
- Update all non-major dependencies (mulk/mulkcms2!23) This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [flow-bin](https://github.com/flowtype/flow-bin)... — committed to benkard/mulkcms2 by benkard a year ago
@ben-manes done here: https://github.com/quarkusio/quarkus/pull/30825
@manuelwallrapp yeah the whole array of classes with metrics are missing. I’ll have a closer look either tomorrow or next week.
It’s not only this one. I think we need to record all the metrics-capable ones and I would prefer doing it only if Micrometer is around. I think I will just drop the feature and do things in the processor. It was a nice optimization while we didn’t have conditions but it’s going to be annoying now.
To give you a bit more background:
Your problem is due to
metrics-enabled
which might have not been supported (or supported differently before) and it now triggers the need for a cache class that we don’t enable by default.I think we should enable these classes by default if we have Micrometer around. I’ll have a look at it next week.
In the meantime, just register the class manually as explained in the guide pointed above.