6 Replies Latest reply on Feb 24, 2015 5:20 AM by nikhilraj

    Problem with Errai Marshalling

    nikhilraj

      I am using errai 3.1.1.Final along with GWT 2.7.0 to communicate with some REST services. One of the services is a PUT accepting a list of Objects (quite heavy weight ones). The service invocation works fine when the size of this list is small (say <100) but as soon as the list exceeds 100, something seems to screw up the marshaller. For any list containing more than 100 objects, the marshaller erroneously injects '^Value' as the identifier of a random field in the generated JSON. There seems to be some correlation between the location of this error and the size of the list.

      I have mentioned two examples below:

      \"perils\":[{\"^Value\":\"0.2\"}],
      
      

       

      \"status\":\"NEW\"},{\"^Value\":\"0.01\"},{\"id\":\"1859210\",
      
      

       

      Could you please help me out with this?

        • 1. Re: Problem with Errai Marshalling
          csa

          Hi,

           

          It seems you have Jackson marshalling enabled on the client. Is this correct? ^Value is actually pointing to Errai's build-in marshalling format which is transformed to Jackson (if enabled), thereby removing all Errai-specific qualifiers.

           

          I just tested marshalling a list with 2000 objects without any problem. So my assumption is that there's a structural difference in your working and failing cases. Can you provide more details or a way for us to reproduce?

           

          Cheers,

          Christian

          • 2. Re: Problem with Errai Marshalling
            nikhilraj

            Hi,

             

            Yes, I do have Jackson marshaling enabled on the client. I think that the issue has to do with the overall size of the resulting JSON rather than the actual size of the list. Could you please have a look at the attached file containing the JSON output produced for a list containing ~500 heavy weight objects?

            It should not be due to any structural difference as the same service call succeeds if I split the exact same list into chunks of 50 objects without any other change in the client or server components.

            Don't know if this would be of help to you - In the attached file, you can see the '^Value' text once and its position shifts around based on the size of the list. But when I doubled the size of the same list, the '^Value' text appeared twice.

             

            Regards,

            Nikhil

            • 3. Re: Problem with Errai Marshalling
              csa

              Hi,

               

              Here's what you can do so we can reproduce this:

               

              String erraiJson = Marshalling.toJson(yourList);

              String jackson = JacksonTransformer.toJackson(erraiJson);

               

              If you could attach both Strings we should be able to reproduce this on our end. Of course, it would be even easier if you could step through the .toJackson call and see why there' s ^Value left-over.

               

              Thanks,

              Christian

              1 of 1 people found this helpful
              • 4. Re: Re: Problem with Errai Marshalling
                nikhilraj

                Hi,

                 

                Please find the strings in the attached files.

                I shall, as you have suggested, try to step through the code and find out the cause for this. But the size of the strings have been posing an issue till now.

                 

                Thanks,

                Nikhil

                • 5. Re: Problem with Errai Marshalling
                  csa

                  Thanks! I was able to reproduce and fix the issue now. Upgrading to 3.1.2-SNAPSHOT (or 3.2.0-SNAPSHOT) will resolve this.

                   

                  The problem was actually caused by an object id collision in the payload. If you search for ObjectID": "563" in your erraiJson you will find a PlotModel and a BigInteger with the same id. These ids are used for resolving back references so we can avoid unnecessary duplication in the payload.

                   

                  Cheers,

                  Christian

                  • 6. Re: Problem with Errai Marshalling
                    nikhilraj

                    Thanks a lot!

                     

                    Cheers,

                    Nikhil