Expand my Community achievements bar.

"String is too long" error when attempting to retrieve jcr:data

Avatar

Level 3
    java.lang.IllegalStateException: String is too long: 2318847350793139939 at org.apache.jackrabbit.oak.plugins.segment.Segment.loadString(Segment.java:397) at org.apache.jackrabbit.oak.plugins.segment.Segment.readString(Segment.java:364) at org.apache.jackrabbit.oak.plugins.segment.Segment.readString(Segment.java:358) at org.apache.jackrabbit.oak.plugins.segment.SegmentPropertyState.getValue(SegmentPropertyState.java:174) at org.apache.jackrabbit.oak.plugins.segment.SegmentPropertyState.getValue(SegmentPropertyState.java:165) at org.apache.jackrabbit.oak.plugins.value.ValueImpl.getValue(ValueImpl.java:381) at org.apache.jackrabbit.oak.plugins.value.ValueImpl.getOakString(ValueImpl.java:144) at org.apache.jackrabbit.oak.plugins.value.ValueImpl.getString(ValueImpl.java:287) at org.apache.jackrabbit.oak.jcr.session.PropertyImpl.getString(PropertyImpl.java:273)

I believe this to be a similar question to http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

So for the situation I am testing I have a file that I am trying to reference in the repository.  I tried this with the "basic" file (two records of 8 lines each) and was unable to reproduce the error in the test regions.  On the other hand I test with the actual file (> 140 records) that I am hoping to reference as soon as I try to pull back the string I get this error.  So for now, I am going to work around this by splitting up the file which should allow me to pull back each file by itself and get what I need from it.

What my actual question is why is there a limit and is there a way to override it for this situation only?  I only ask because the solution I am using currently works fine on my Windows 10 based machine but gets this error in both of our test regions (and I am assuming our Prod region, but I am not going to test that for obvious reasons) which are Linux based.

BTW, we are on AEM 6.1 and have the hotfix installed so we are on Apache Jackrabbit Oak 1.2.14.

Thanks in advance for any help that you can provide.

Brad W.

7 Replies

Avatar

Level 10

Please raise a support ticket to quickly see if they have any workarounds already !

Avatar

Administrator

Please file a day care ticket for this: https://daycare.day.com/home/createaticket.html 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 4

Was an answer to this issue ever provided?

I was running the "debug" option on my oak 1.4.9 repository today and received the same exception.

Exception in thread "main" java.lang.IllegalStateException: String is too long: 2318847148929820343
        at org.apache.jackrabbit.oak.plugins.segment.Segment.loadString(Segment.java:533)

Avatar

Level 1

I am facing a similar issue in AEM 6.5.1. Is there any solution for this?

Avatar

Level 3

Hi @nafeeskhanp7683
Probably the problem that you have is the size of file.
To read big .TXT files you will need to open it as Stream and read parts until the EOF (End of File).

This isn't a good code, but is a sample reading by byte.

var csvBin = workflowSession.getSession().getNode(path + "/attachments/csvUpload/" + csvName + "/jcr:content").getProperty("jcr:data").getBinary();
        var csvStream = csvBin.getStream()
        var csv = [];
        while(1) {
            var csvLine = [];
            var endFlag = false;
            while(1) {
                var charCode = csvStream.read();
                if(charCode == -1) {
                    endFlag = true;
                    break;
                }
                var char =  String.fromCharCode(charCode);
                if(char == "\n") break;
                csvLine.push(char);
            }
            if(endFlag == true) break;
            csv.push(csvLine.join(""));
        }

Avatar

Level 2

Hi @b7wilso 

To resolve this issue...first, get the "JCR: data" value as binary and this binary will return you an InputStream. After that convert that InputStream to a String value using the following method :

 String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);

That's it...Your Exception will be resolved now...
Thanks
Ramesh Kumar