Highlighted

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

b7wilso

09-06-2016

    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.

Replies

Highlighted

Tom_Fought

17-05-2017

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)

Highlighted

Jean-foxfly

21-07-2020

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(""));
        }