0

I am currently configured my cache container in JBoss 7.4 standalone.xml, and the ISPN remote server running on localhost. Everything was fine until it throws the error:

ISPN000492: Cannot find transcoder between 'application/x-jboss-marshalling' to 'application/x-protostream'

standalone.xml:

         <remote-cache-container name="remoteContainer" default-remote-cluster="data-grid-cluster">
            <property name="infinispan.client.hotrod.sasl_mechanism">SCRAM-SHA-512</property>
            <property name="infinispan.client.hotrod.auth_realm">default</property>
            <property name="infinispan.client.hotrod.auth_username">admin</property>
            <property name="infinispan.client.hotrod.auth_password">12345</property>
            <property name="infinispan.client.hotrod.client_intelligence">BASIC</property>
            <remote-clusters>
                <remote-cluster name="data-grid-cluster" socket-bindings="ispn1 ispn2"/>
            </remote-clusters>
        </remote-cache-container>

ISPN Cache configuration:

{ "distributed-cache": { "mode": "SYNC", "owners": 2, "encoding": { "key": { "media-type": "application/x-protostream" }, "value": { "media-type": "application/x-protostream" } }, "expiration": { "lifespan": 5000, "max-idle": 1000 }, "statistics": true } }

Note: I don't want to change the cache encoding because the infinispan web console stops working

grf2018
  • 3
  • 5

1 Answers1

0

The error is saying the client cache has media type application/x-jboss-marshalling, and you want application/x-protostream instead.

Looking at the WildFly 23.x code, it will use ProtoStreamMarshaller (and media type application/x-protostream) iff the application has a SerializationContextInitializer implementation in its classpath.

Even if you only store strings and primitives in the cache, you still have to write an interface and annotate it with @AutoProtoSchemaBuilder for RemoteCacheContainerConfigurationServiceConfigurator to choose ProtoStreamMarshaller.

In WildFly 24.x the auto-detection mechanism changes, and ProtoStreamMarshaller is picked if the modules attribute includes org.wildfly.clustering.web.hotrod, so <remote-cache-container modules="org.wildfly.clustering.web.hotrod"> might also work on 23.x.

In Wildfly 24.x you can always set <remote-cache-container marshaller="PROTOSTREAM"> to choose ProtoStreamMarshaller manually.

Dan Berindei
  • 7,054
  • 3
  • 41
  • 48
  • Thanks for response! u have an example of implement an interface of @AutoProtoSchemaBuilder? – grf2018 May 22 '22 at 22:50
  • See https://infinispan.org/docs/stable/titles/encoding/encoding.html#annotating-autoprotoschemabuilder_marshalling – Dan Berindei May 24 '22 at 10:01
  • In my case only I store a simple String on cache not a Object, how i can do that? ty – grf2018 May 24 '22 at 17:37
  • IIRC you can write an interface and annotate it with `@AutoProtoSchemaBuilder` even if you don't have any custom classes and you leave the `includeClasses` empty. But it does complicate your life a bit because you have to make sure the annotation processor runs and generates the service loader file in `META-INF/services`. I'd much rather upgrade to WildFly 24+, which doesn't need this any more because it lets you select the marshaller directly. – Dan Berindei May 25 '22 at 11:00
  • Thank you, actually I use JBoss EAP 7.4. You recommend me upgrade to WilfFly 24+? What is Jboss's version equivalent? What is true is that the cache works fine, and the only disadvantage is the web console of the server that does not show the entries but the rest works fine! – grf2018 May 25 '22 at 14:41
  • No, I wouldn't recommend moving from EAP to WildFly just for this... I'd say instead follow the steps in the link I posted and let the ProtoStream annotation processor create a dummy SerializationContextInitializer, or even write a class implementing SerializationContextInitializer to do nothing yourself and put a reference to it in `META-INF/services` manually if you'd rather avoid the dependency. I forgot to mention earlier, but if you're only using strings then `text/plain` is also an option, and IIRC the web console also works with `text/plain`. – Dan Berindei May 30 '22 at 13:32
  • Thank for response! My app runs on EAP 7.4 and I tried to configure the cache with encode "text/plain" but i got the following error when i put an entry: ISPN004005: Error received from the server: org.infinispan.commons.dataconversion.EncodingException: ISPN000495: JBossMarshallingTranscoder encountered error transcoding content java.io.IOException: Unsupported protocol version 1 – grf2018 May 30 '22 at 20:59
  • { "distributed-cache": { "mode": "SYNC", "owners": 2, "encoding": { "key": { "media-type": "text/plain" }, "value": { "media-type": "text/plain" } }, "expiration": { "lifespan": 5000, "max-idle": 1000 }, "statistics": true } } – grf2018 May 30 '22 at 21:01
  • Sorry, I read "I don't want to change the cache encoding" in your question and I assumed you can change the encoding in the client configuration! Looking at the code I'm not sure the RemoteCacheContainer abstraction in WildFly/EAP is meant to support the full range of marshallers/encodings that the underlying Infinispan cache container supports. – Dan Berindei May 30 '22 at 23:33
  • Maybe there are no solution for this. In jboss eap 7.4 is not possible change the encoding jboss-marshaller. – grf2018 May 31 '22 at 01:18
  • Except for protostream :) You *can* change the marshaller to protostream if you add an implementation of `SerializationContextInitializer` to your application, it's just a bit annoying to have to write/generate that implementation when you only need strings. – Dan Berindei May 31 '22 at 12:22