quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Quarkus Infinispan DevServices not working anymore? #30433

Closed jonsalvas closed 1 year ago

jonsalvas commented 1 year ago

Describe the bug

According to the docs it should be possible to create cache such as:

https://quarkus.io/guides/infinispan-client#creating-caches-from-the-client quarkus.infinispan-client.cache.books.configuration-uri=cacheConfig.json quarkus.infinispan-client.cache.magazine.configuration=<distributed-cache><encoding media-type="application/x-protostream"/></distributed-cache> And as far as I understand I can use this cache

 @Inject
  @Remote("books")
  RemoteCache<String, Book> cache;

But when I start my quarkus app with devservices enabled, and trying to access the cache I get:

org.infinispan.server.hotrod.CacheNotFoundException: Cache with name 'test' not found amongst the configured caches

According to the docs the cache name can be removed, so the default cache should be used. This is also not working:

 org.infinispan.server.hotrod.CacheNotFoundException: Default cache requested but not configured

Am I missing something? Or is the DevServer not configured correctly?

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

Hello.java

@Path("/hello")
public class HelloResource {

    private static final Logger LOG = Logger.getLogger(HelloResource.class);
   @Inject @Remote("mycache")
    RemoteCache<String, Object> cache;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public void hello() {
        LOG.info(cache.get("abc"));
    }
}

application.properties

quarkus.infinispan-client.mycache.configuration=<distributed-cache name="mycache"><encoding media-type="application/x-protostream"/></distributed-cache>

Output of uname -a or ver

Darwin nbipmac027.local 21.6.0 Darwin Kernel Version 21.6.0: Sun Nov 6 23:31:16 PST 2022; root:xnu-8020.240.14~1/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment Homebrew (build 11.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)

GraalVM version (if different from Java)

22.3

Quarkus version or git rev

2.15.3.Final or 2.10.2

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /usr/local/Cellar/maven-noopenjdk/3.8.4/libexec Java version: 11.0.12, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@11/11.0.12/libexec/openjdk.jdk/Contents/Home Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "12.6.2", arch: "x86_64", family: "mac"

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @geoand (devservices), @karesti (infinispan), @stuartwdouglas (devservices), @wburns (infinispan)

gsmet commented 1 year ago

Please attach a simple reproducer so that @karesti can have a look. Thanks.

jonsalvas commented 1 year ago

OK I just tried the same with a remote server and the issues persists, so I assume it is not related to DevServices. It seems that 1. Infinispan has no default cache (anymore?). When I use the web console I only see "respCache". 2. the quarkus extension does not create it correctly using the quarkus.infinispan-client.cache.xxxx.configuration... like described in the documentation

karesti commented 1 year ago

Infinispan hasn't a default cache anymore, indeed. We create one in the extension during the injection with a minimal default configuration if it does not exist. If we add a config for a cache like described in the documentation, this cache is created using the provided configuration on first access

I tried the Quarkus Quickstart and works for me. https://github.com/quarkusio/quarkus-quickstarts/compare/main...karesti:quarkus-quickstarts:create-first-access

Please, provide a reproducer and let us know which server version is running

jonsalvas commented 1 year ago

thanks for the link to the quarkus quickstart! It helped me to figure out how it is working. I think I missed the fact that the "missing cache" message was only a WARN and I missed the line "Attempt to create cache using minimal default config", therefore I was a bit confused :-). Thanks and sorry for the confusion. I will close this issue.

karesti commented 1 year ago

@jonsalvas I will split the Infinispan Client Guide in two, will probably help to dive into the quickstart and then having the extension reference