Apache TIKA:尝试分配长度为1835606的数组,但此记录类型的最大值为1000000

问题描述

运行Apache Ticka 1.24.1,如下所示:

java -Xmx3G -Djava.io.tmpdir=/mytmp/tmp -spawnChild -taskpulseMillis 240000 -jar tika-server.jar --host=hostname.domain.com

可以将数组长度更改为不出现此错误吗?

org.apache.tika.exception.TikaException: Unexpected RuntimeException 
from org.apache.tika.parser.microsoft.OfficeParser@4fab9c0a
...
...
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: org.apache.poi.util.RecordFormatException: Tried to allocate 
an array of length 1835606,but 1000000 is the maximum for this record type.
If the file is not corrupt,please open an issue on bugzilla to request 
increasing the maximum allowable size for this record type.
As a temporary workaround,consider setting a higher override value with 
IoUtils.setByteArrayMaxOverride()
at org.apache.poi.util.IoUtils.throwRFE(IoUtils.java:630)
at org.apache.poi.util.IoUtils.checkLength(IoUtils.java:208)
at org.apache.poi.util.IoUtils.safelyAllocateCheck(IoUtils.java:610)
at org.apache.poi.util.IoUtils.safelyAllocate(IoUtils.java:596)
at org.apache.poi.hmef.attribute.MAPIRtfAttribute.<init 
(MAPIRtfAttribute.java:49)
...
org.apache.tika.parser.microsoft.OutlookExtractor.handleBodyChunks(
OutlookExtractor.java:328)

解决方法

请在您的tika-config.xml中添加以下配置,并让我们知道它是否有效。

<?xml version="1.0" encoding="UTF-8"?>
<properties>
    <parsers>
        <parser class="org.apache.tika.parser.DefaultParser"/>
        <parser class="org.apache.tika.parser.microsoft.OfficeParser">
            <params>
                <param name="byteArrayMaxOverride" type="int">2000000</param>

            </params>
        </parser>
    </parsers>
</properties>