2 Replies Latest reply on Sep 29, 2014 3:21 AM by dalbani

    Can't set a STRING property more than 4096  bytes long




      To begin with, here's my environment: ModeShape 4.0.0.Beta1, storage on Infinispan, using a LevelDB backend.


      Here's the exception that I get when I set a value of 4096+ bytes to a STRING property:


      21:01:18,790 DEBUG [org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore]  Binary value already exist.
      21:01:21,820 DEBUG [org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore]  Store binary value into chunks.
      21:01:21,821 DEBUG [org.modeshape.jcr.value.binary.infinispan.ChunkOutputStream]  Close. Buffer size at close: 5127
      21:01:21,822 DEBUG [org.modeshape.jcr.value.binary.infinispan.ChunkOutputStream]  Store chunk 69b0c6dbf78e0eabaf558075f47f80c3debe5aad-data-0
      21:01:21,839 INFO [stdout] java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
      21:01:21,839 INFO [stdout]  javax.jcr.RepositoryException: java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
      21:01:21,839 INFO [stdout]         at org.modeshape.jcr.JcrSession.save(JcrSession.java:1184)
      21:01:21,844 INFO  [stdout]  Caused by: java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
      21:01:21,844 INFO  [stdout]         at org.modeshape.common.util.StringUtil.createString(StringUtil.java:169)
      21:01:21,844 INFO  [stdout]         at org.modeshape.common.i18n.I18n.text(I18n.java:412)
      21:01:21,844 INFO  [stdout]         at org.modeshape.common.i18n.I18n.text(I18n.java:397)
      21:01:21,844 INFO  [stdout]         at org.modeshape.jcr.value.binary.BinaryStoreValueFactory.create(BinaryStoreValueFactory.java:232)
      21:01:21,845 INFO  [stdout]         at org.modeshape.jcr.value.binary.BinaryStoreValueFactory.create(BinaryStoreValueFactory.java:104)
      21:01:21,845 INFO  [stdout]         at org.modeshape.jcr.value.binary.BinaryStoreValueFactory.create(BinaryStoreValueFactory.java:49)
      21:01:21,845 INFO  [stdout]         at org.modeshape.jcr.cache.document.DocumentTranslator.valueToDocument(DocumentTranslator.java:1090)
      21:01:21,845 INFO  [stdout]         at org.modeshape.jcr.cache.document.DocumentTranslator.setProperty(DocumentTranslator.java:421)
      21:01:21,846 INFO  [stdout]         at org.modeshape.jcr.cache.document.WritableSessionCache.persistChanges(WritableSessionCache.java:1006)
      21:01:21,846 INFO  [stdout]         at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:587)
      21:01:21,846 INFO  [stdout]         at org.modeshape.jcr.JcrSession.save(JcrSession.java:1165)
      21:01:21,846 INFO  [stdout]         ... 19 more


      There's a BinaryStoreException that is thrown in BinaryStoreValueFactory.create(BinaryStoreValueFactory.java:232) but I don't know its content as the creation of the ValueFormatException just below... throws an exception too!


      I suppose that what I'm seeing is somewhat related to the ModeShape optimization feature mentioned in MODE-2155.

      Indeed, setting <cache-binary-storage ... min-string-size="2147483647"/> made my problem disappear.

      But that's more of a workaround that a proper solution.

      Before opening a bug report in JIRA, I wanted to be sure that it's not due to an incorrect configuration of mine.


        • 1. Re: Can't set a STRING property more than 4096  bytes long

          The exception itself is obviously a bug caused by an incorrect message conversion. Also, there may be another bug related to the "min-string-size" and the InfinispanBinaryStore. So please feel free to open the JIRA around this.


          In general however, if you plan/want to store large strings as strings and not binaries, you have to set the "min-string-size" setting on the binary store implementation that you're using. The issue you mentioned describes this, together with Binary values - ModeShape 4 - Project Documentation Editor. This is a conscious design decision and it has to do with the fact that storing large strings in your node properties (as opposed to using binary values) will increase the size of the document entry stored in Infinispan and will not be optimized in any way (again unlike binaries). The above link describes the binary storage mechanism in more detail.

          • 2. Re: Can't set a STRING property more than 4096  bytes long

            Thanks for your response.

            I've opened a bug report: MODE-2322.