Skip to content
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

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

Closed
dmadunic opened this issue Aug 16, 2022 · 10 comments · Fixed by #29046
Closed

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

dmadunic opened this issue Aug 16, 2022 · 10 comments · Fixed by #29046
Labels
area/gradle Gradle area/infinispan Infinispan area/kotlin kind/bug Something isn't working
Milestone

Comments

@dmadunic
Copy link

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.

@dmadunic dmadunic added the kind/bug Something isn't working label Aug 16, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 16, 2022

/cc @evanchooly, @geoand, @glefloch, @karesti, @quarkusio/devtools, @wburns

@geoand
Copy link
Contributor

geoand commented Sep 2, 2022

Do have a sample application you can attach so we can investigate?

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Sep 2, 2022
@dmadunic
Copy link
Author

dmadunic commented Sep 5, 2022

I have created a small test application, and it is available here: https://github.com/dmadunic/infinispan-quarkus-test

it has both gradle and maven build tools in it.

To reproduce the problem, after cloning the repo, first start infinispan server with the credentials admin/secret.

Now run the following command to start the app:

./mvnw compile quarkus:dev

Once the app is up invoke the url: http://localhost:8080/author/joe and all should work well. If you invoke this url twice you will get the same cached result.

Now run the app with the gradle as the build tool:

./gradlew clean quarkusDev

and again invoke the same url: http://localhost:8080/authors/joe this time you will get the following exception:

java.lang.IllegalArgumentException: No marshaller registered for Protobuf type book_sample.Author
	at org.infinispan.protostream.impl.SerializationContextImpl.getMarshallerDelegate(SerializationContextImpl.java:450)
	at org.infinispan.protostream.WrappedMessage.readMessage(WrappedMessage.java:535)
	at org.infinispan.protostream.WrappedMessage.read(WrappedMessage.java:351)
	at org.infinispan.protostream.ProtobufUtil.fromWrappedByteArray(ProtobufUtil.java:129)
	at org.infinispan.commons.marshall.ImmutableProtoStreamMarshaller.objectFromByteBuffer(ImmutableProtoStreamMarshaller.java:31)
	at org.infinispan.commons.marshall.AbstractMarshaller.objectFromByteBuffer(AbstractMarshaller.java:82)
	at org.infinispan.client.hotrod.marshall.MarshallerUtil.bytes2obj(MarshallerUtil.java:57)
	at org.infinispan.client.hotrod.DataFormat.valueToObj(DataFormat.java:155)

I hope this is enough to reproduce the problem.

@dmadunic
Copy link
Author

Any feedback?

@geoand
Copy link
Contributor

geoand commented Oct 5, 2022

@karesti we now have a reproducer for this (thanks @dmadunic), can you have a look?

@geoand geoand removed the triage/needs-reproducer We are waiting for a reproducer. label Oct 14, 2022
@karesti
Copy link
Member

karesti commented Oct 27, 2022

we are investigating this in protostream https://issues.redhat.com/browse/IPROTO-249

@wburns
Copy link
Member

wburns commented Oct 27, 2022

I am not familiar with gradle but I thought you had to specify the annotation processors explicitly in the dependencies as the annotationProcessor 'org.infinispan.protostream:protostream-processor' type no?

@geoand
Copy link
Contributor

geoand commented Oct 31, 2022

I thought you had to specify the annotation processors explicitly in the dependencies as the annotationProcessor 'org.infinispan.protostream:protostream-processor' type no

AFAIK, this is true. So should this be closed as an invalid issue?

@karesti
Copy link
Member

karesti commented Nov 2, 2022

We are going to put a comment in the docs @geoand

@geoand
Copy link
Contributor

geoand commented Nov 2, 2022

Great idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gradle Gradle area/infinispan Infinispan area/kotlin kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants