1 2 Previous Next 17 Replies Latest reply on Jul 6, 2017 10:20 AM by sea_shankar

    Compatibility mode on requires Java Pojos to be registered in hot rod server?

    sea_shankar

      I was curious about how compatbility mode works.  If it's turned on, I get errors when trying to put any Java Pojos into the cache with a NoClassDef found error.  Does this mean that with compatibility mode on, I would have to register every Java Pojos with the server?

        • 1. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
          gustavonalle

          You are right, since with compatibility mode your objects will be stored in un-serialized fashion, the server needs to be aware of those classes.

           

          We are working on making this registration process easier, but at the moment the way to achieve this is as following:

           

          1) Pack you pojos into a jar file, let's call it pojos.jar

          2) Using the CLI (located in the server bin/  folder), create a module for those entities:

           

          $ bin/ispn-cli.sh

          [disconnected/] module add --name=com.pojo  --resources=/path/to/pojos.jar                                                                                 

          3) Edit modules/system/layers/base/org/infinispan/commons/main/module.xml and add your pojo as a dependency:

           

          <module name="com.pojo"/>

           

          4) Start the server

          • 2. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
            anistor

            sea_shankar As of infinispan 9.0, compat mode only supports simple types (String, Integer...) while user pojos are not officially supported. But rules can be bent, as shown by gustavonalle's workaround. There is work on the way to officially provide support for this use case starting with infinispan 9.1, but please note the official solution will not be based on this workaround.

            • 3. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
              gustavonalle

              anistor is correct. This should be treated as a workaround, and a not supported solution.

               

              We will provide a way to avoid having to modify Infinispan own modules (step 3) in the next minor release.

              • 4. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                sea_shankar

                Thanks for the quick response! Do either of you know the ISPN task for the official solution?

                • 5. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                  anistor

                  ISPN-6245 and ISPN-6334

                  • 6. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                    anistor

                    @sea_shankar The pull request fixing this has just been merged and infinispan-9.1.0.CR1 will be released today. Please have a look at the documentation changes and see how this applies to your use case. We'd love to have some feedback. Thanks!

                    ISPN-6245 Integration test and fix for deploying custom compat marshaller by anistor · Pull Request #5233 · infinispan/i…

                    • 7. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                      sea_shankar

                      Cool!  Checking it out.

                       

                      I added the following:

                       

                      <compatibility marshaller="org.infinispan.query.remote.CompatibilityProtoStreamMarshaller"/>

                       

                      but I get the following error, some dependency I need to add.  I only have spring4remote and infinispan-spring-boot-starter:

                       

                      finispan_1  | [Server:server-two] 22:46:10,080 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 27) WFLYCTL0013: Operation ("add") failed - address: ([

                      infinispan_1  | [Server:server-two]     ("subsystem" => "datagrid-infinispan"),

                      infinispan_1  | [Server:server-two]     ("cache-container" => "clustered"),

                      infinispan_1  | [Server:server-two]     ("configurations" => "CONFIGURATIONS"),

                      infinispan_1  | [Server:server-two]     ("distributed-cache-configuration" => "configuration")

                      infinispan_1  | [Server:server-two] ]): java.lang.IllegalArgumentException: DGISPN0119: org.infinispan.query.remote.CompatibilityProtoStreamMarshaller is not a valid marshaller

                      infinispan_1  | [Server:server-two]   at org.jboss.as.clustering.infinispan.subsystem.CacheConfigurationAdd.processModelNode(CacheConfigurationAdd.java:498)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.clustering.infinispan.subsystem.ClusteredCacheConfigurationAdd.processModelNode(ClusteredCacheConfigurationAdd.java:69)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.clustering.infinispan.subsystem.SharedStateCacheConfigurationAdd.processModelNode(SharedStateCacheConfigurationAdd.java:48)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.clustering.infinispan.subsystem.DistributedCacheConfigurationAdd.processModelNode(DistributedCacheConfigurationAdd.java:68)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.clustering.infinispan.subsystem.CacheConfigurationAdd.installRuntimeServices(CacheConfigurationAdd.java:225)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.clustering.infinispan.subsystem.CacheConfigurationAdd.performRuntime(CacheConfigurationAdd.java:202)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.controller.AbstractAddStepHandler.performRuntime(AbstractAddStepHandler.java:337)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.controller.AbstractAddStepHandler$1.execute(AbstractAddStepHandler.java:151)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:890)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:659)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:370)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:359)

                      infinispan_1  | [Server:server-two]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                      infinispan_1  | [Server:server-two]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                      infinispan_1  | [Server:server-two]   at java.lang.Thread.run(Thread.java:745)

                      infinispan_1  | [Server:server-two]   at org.jboss.threads.JBossThread.run(JBossThread.java:320)

                      infinispan_1  | [Server:server-two] Caused by: java.lang.ClassNotFoundException: org.infinispan.query.remote.CompatibilityProtoStreamMarshaller from [Module "org.infinispan:main" from local module loader @629f0666 (finder: local module finder @1bc6a36e (roots: /opt/jboss/infinispan-server/modules,/opt/jboss/infinispan-server/modules/system/layers/base))]

                      infinispan_1  | [Server:server-two]   at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)

                      infinispan_1  | [Server:server-two]   at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)

                      infinispan_1  | [Server:server-two]   at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)

                      infinispan_1  | [Server:server-two]   at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)

                      infinispan_1  | [Server:server-two]   at org.jboss.as.clustering.infinispan.subsystem.CacheConfigurationAdd.processModelNode(CacheConfigurationAdd.java:495)

                      infinispan_1  | [Server:server-two]   ... 15 more

                      infinispan_1  | [Server:server-two]

                      infinispan_1  | [Server:server-two] 22:46:10,086 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) "WFLYCTL0193: Failed executing subsystem datagrid-infinispan boot operations"

                       

                      Even if i using the stock marshaller, do I assume the jar still has to be deployed?

                       

                      Also, what is the steps to deploy the jar? 

                       

                      This part says:

                       

                      <!-- using a marshaller deployed as a regular jar deployed by dropping it in the 'deployments' folder -->

                      <compatibility marshaller="deployment.my-jar-with-gadgets.jar:main:com.acme.CustomCompatMarshaller"/>

                       

                      However, I using domain configuration and there are no deployments folder under domain like there is in standalone? 

                      • 8. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                        anistor

                        You do not need to deploy anything for CompatibilityProtoStreamMarshaller, this is a stock marshaller from infinispan. It's very odd that you are getting a ClassNotFoundException.

                        ISPN-7710 has fixed the particular case of CompatibilityProtoStreamMarshaller, while ISPN-6245 has fixed the general case of deploying a marshaller from an external jar, and we have test coverage for all these cases.

                        Are you sure you are really using the newly released 9.1.0.CR1 server?

                         

                        Deployment of jars (in both standalone and domain mode) is done through the CLI. Please look into the Wildfly documentation for that (Application deployment - WildFly 10 - Project Documentation Editor ).

                        A handy shortcut in standalone mode is to deploy the jar by copying it to the 'deployments' folder, which you are right, is missing in domain mode, I'll have to fix this in our user guide and suggest using the CLI. Thanks for spotting this.

                        • 9. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                          sea_shankar

                          Cool yea I have deployed server tasks using the cli and for this specific use case I am good with the stock marshaller.

                           

                          Ahh you are right, I was using a docker image pointing to the latest image: jboss/infinispan-server:latest and my guess is this is probably not pointing to 9.1.0.CR1?  I looked at https://hub.docker.com/r/jboss/infinispan-server/tags didn't see one for 9.1.0.CR1?

                          • 10. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                            anistor

                            Should be there now.

                            • 11. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                              sea_shankar

                              I got the following error trying to use the stock marshaller:

                               

                              2017-06-30 17:16:19 WARN [XNIO-2 task-1] o.i.c.h.i.p.Codec21 [Codec20.java:361] - ISPN004005: Error received from the server: protostream.com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).

                              2017-06-30 17:16:19 ERROR [XNIO-2 task-1] c.g.c.e.ServiceExceptionHandler [ServiceExceptionHandler.java:58] - Generic Exception Handler:

                              org.infinispan.client.hotrod.exceptions.HotRodClientException: protostream.com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).

                                at org.infinispan.client.hotrod.impl.protocol.Codec20.checkForErrorsInResponseStatus(Codec20.java:363)

                                at org.infinispan.client.hotrod.impl.protocol.Codec20.readPartialHeader(Codec20.java:152)

                                at org.infinispan.client.hotrod.impl.protocol.Codec20.readHeader(Codec20.java:138)

                                at org.infinispan.client.hotrod.impl.operations.HotRodOperation.readHeaderAndValidate(HotRodOperation.java:60)

                                at org.infinispan.client.hotrod.impl.operations.AbstractKeyOperation.sendKeyOperation(AbstractKeyOperation.java:51)

                                at org.infinispan.client.hotrod.impl.operations.GetOperation.executeOperation(GetOperation.java:31)

                                at org.infinispan.client.hotrod.impl.operations.RetryOnFailureOperation.execute(RetryOnFailureOperation.java:56)

                                at org.infinispan.client.hotrod.impl.RemoteCacheImpl.get(RemoteCacheImpl.java:355)

                                at org.infinispan.spring.provider.CacheDelegate.get(CacheDelegate.java:60)

                                at org.infinispan.spring.provider.SpringCache.get(SpringCache.java:51)

                                at org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:71)

                                at org.springframework.cache.interceptor.CacheAspectSupport.findInCaches(CacheAspectSupport.java:537)

                                at org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:503)

                                at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:389)

                                at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:327)

                                at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)

                                at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

                                at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)

                               

                              I am using the spring annotation @Cacheable and what it is caching is a List<JavaPojo> and the pojo contains LocalDate, BigDecimal, and String object if that matters. 

                              • 12. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                                anistor

                                You are not saying how are you registering the message marshallers for your types (and for LocalDate and BigDecimal). Are you using the 'server task approach' ?

                                • 13. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                                  sea_shankar

                                  Do you mean to say I need to create a .proto file and create a MessageMarshaller (similar to this project: swiss-transport-datagrid/Train.java at 2e095cad0382a72751d7058ebe1af5de465745ee · infinispan-demos/swiss-transport-datag… ? And then register the marshaller with the client and server?

                                  • 14. Re: Compatibility mode on requires Java Pojos to be registered in hot rod server?
                                    anistor

                                    Yes, since you are using compat mode + protobuf, you should do that. The sample you mentioned is what you need.

                                    1 2 Previous Next