Skip to content

Infinispan client extension does not work with gradle as build tool #27318

@dmadunic

Description

@dmadunic

Describe the bug

Following the steps in the guide for quarkus-infinispan extension (https://quarkus.io/guides/infinispan-client#dependency-injection) if application is using gradle as build system, while puting an object to the cache the following error will occur:
java.lang.IllegalArgumentException: No marshaller registered for object of Java type org.acme.domain.Book : Book [authors=[Author [name=Sean, surname=Scott]], description=b, price=100, publicationYear=5, title=a]

Expected behavior

For error not to occur

Actual behavior

When an item is put into, or retrieved from a cache, you receive an IllegalArgument exception that the proto marshaller isn't registered for the class.
This happens because no protobuf marshaller classes are generated.

How to Reproduce?

Steps to reproduce the behavior:

  1. Create a new quarkus gradle project with the following extensions: quarkus-resteasy, quarkus-resteasy-jsonb, quarkus-infinispan-client)
  2. Follow the infinispan client quick start guide... use the annotations approach described (Author, Book, BookStoreSchema )
  3. Start an infinispan server and
  4. Configure the connection properties in the application.properties file, as follows:
application.name=quarkusInfinispanDemo
quarkus.infinispan-client.server-list=localhost:11222
# Authentication
quarkus.infinispan-client.auth-username=admin
quarkus.infinispan-client.auth-password=secret
quarkus.infinispan-client.sasl-mechanism=DIGEST-MD5

cache=<infinispan><cache-container><replicated-cache name="<name-override>"><encoding><key media-type="text/plain"/><value media-type="application/x-protostream"/></encoding></replicated-cache></cache-container></infinispan>
  1. Modify GreetingResource so that cache is used when /hello path is invoked
@Path("/hello")
public class GreetingResource {

    @Inject
    RemoteCacheManager remoteCacheManager;

    @ConfigProperty(name = "cache")
    String cacheConfiguration;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        Book b = new Book("a","b",5, Set.of(new Author("Sean","Scott")), new BigDecimal(100d));
        getCache().put("hi",b);
        getCache().get("hi");
        return "hello";
    }

    public RemoteCache<String,Book> getCache(){
        return remoteCacheManager.administration().getOrCreateCache(
            "books", 
            new XMLStringConfiguration(cacheConfiguration.replace("<name-override>", "books"))    
        );
    }
}
  1. Invoke the endpoint: http://localhost:8080/hello and you should see the internal server error screen with the following exception:
    java.lang.IllegalArgumentException: No marshaller registered for object of Java type org.acme.domain.Book : Book [authors=[Author [name=Sean, surname=Scott]], description=b, price=100, publicationYear=5, title=a]
    at org.infinispan.protostream.impl.SerializationContextImpl.getMarshallerDelegate(SerializationContextImpl.java:503)
    at org.infinispan.protostream.WrappedMessage.writeMessage(WrappedMessage.java:281)
    at org.infinispan.protostream.WrappedMessage.write(WrappedMessage.java:242)
    ...

Output of uname -a or ver

Linux domagoj-TUXEDO-Book-XP14-Gen12 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

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

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.11.2.Final

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

------------------------------------------------------------ Gradle 7.4.2 ------------------------------------------------------------ Build time: 2022-03-31 15:25:29 UTC Revision: 540473b8118064efcc264694cbcaa4b677f61041 Kotlin: 1.5.31 Groovy: 3.0.9 Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021 JVM: 11.0.12 (Oracle Corporation 11.0.12+7) OS: Linux 5.15.0-46-generic amd64

Additional information

No Marshaller classes are generated inside build/ folder. On the other hand when the same steps are repeated but with the application using maven as the build tool, all works fine.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions