-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data cache not working when using the programmatic API #22538
Comments
/cc @gwenneg |
Hi @argenstijn and thanks for creating this issue. The behavior you described is actually intentional. As explained in the quarkus-cache doc:
The programmatic caching API is currently composed of two entry points: Declaring a cache is not currently supported with I think we could change things a bit and support the creation of a cache declared with |
thanks for the explanation. Yes, the documentation had an example without @CacheInvalidate and that was a bit confusing: _CacheManager#getCache will still not support the creation of a cache because caches are instantiated at build time and there is not way to know at that moment which value will be passed to CacheManager#getCache at runtime. Maybe by defining a property? With kind regards, |
Hi! I am experiencing the same problem here.
I liked the solution, it would be great if
I would like to express a positive vote for this solution as well. |
Close issue as the merge was done |
Describe the bug
When using the programmic API of cache you are obliged to use @CacheResult annotation or else you will get the following exception
java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#generateResources threw an exception: javax.enterprise.inject.spi.DeploymentException: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.cache.issue.CacheIssue, cacheName=my-cache]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1196)
at io.quarkus.arc.processor.BeanProcessor.processValidationErrors(BeanProcessor.java:147)
at io.quarkus.arc.deployment.ArcProcessor.generateResources(ArcProcessor.java:483)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.cache.issue.CacheIssue, cacheName=my-cache]
at io.quarkus.cache.deployment.CacheProcessor.validateCacheAnnotationsAndProduceCacheNames(CacheProcessor.java:142)
... 11 more
Caused by: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#generateResources threw an exception: javax.enterprise.inject.spi.DeploymentException: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.cache.issue.CacheIssue, cacheName=my-cache]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1196)
at io.quarkus.arc.processor.BeanProcessor.processValidationErrors(BeanProcessor.java:147)
at io.quarkus.arc.deployment.ArcProcessor.generateResources(ArcProcessor.java:483)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.cache.issue.CacheIssue, cacheName=my-cache]
at io.quarkus.cache.deployment.CacheProcessor.validateCacheAnnotationsAndProduceCacheNames(CacheProcessor.java:142)
... 11 more
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#generateResources threw an exception: javax.enterprise.inject.spi.DeploymentException: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.cache.issue.CacheIssue, cacheName=my-cache]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1196)
at io.quarkus.arc.processor.BeanProcessor.processValidationErrors(BeanProcessor.java:147)
at io.quarkus.arc.deployment.ArcProcessor.generateResources(ArcProcessor.java:483)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.cache.issue.CacheIssue, cacheName=my-cache]
at io.quarkus.cache.deployment.CacheProcessor.validateCacheAnnotationsAndProduceCacheNames(CacheProcessor.java:142)
... 11 more
Caused by: javax.enterprise.inject.spi.DeploymentException: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.cache.issue.CacheIssue, cacheName=my-cache]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1196)
at io.quarkus.arc.processor.BeanProcessor.processValidationErrors(BeanProcessor.java:147)
at io.quarkus.arc.deployment.ArcProcessor.generateResources(ArcProcessor.java:483)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.cache.issue.CacheIssue, cacheName=my-cache]
at io.quarkus.cache.deployment.CacheProcessor.validateCacheAnnotationsAndProduceCacheNames(CacheProcessor.java:142)
... 11 more
Expected behavior
@when injection a cache you should not have to use any 'cache ' annotation with exception of @Cache.
Actual behavior
When only using @Cache it result in the given exception:
Caused by: io.quarkus.cache.deployment.exception.UnknownCacheNameException: A field or method parameter is annotated with a @CacheName annotation referencing an unknown cache name [class=com.nn.aav.insurance.aab.proxy.business.authentication.boundary.OAuth2Filter, cacheName=customerapi]
at io.quarkus.cache.deployment.CacheProcessor.validateCacheAnnotationsAndProduceCacheNames(CacheProcessor.java:142)
... 11 more
How to Reproduce?
Just run the test
cache.zip
Output of
uname -a
orver
Microsoft Windows [Version 10.0.19043.1415]
Output of
java -version
openjdk version "11.0.12" 2021-07-20 LTS OpenJDK Runtime Environment Corretto-11.0.12.7.1 (build 11.0.12+7-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.12.7.1 (build 11.0.12+7-LTS, mixed mode)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
Quarkus 2.6.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.3
Additional information
No response
The text was updated successfully, but these errors were encountered: