intra-mart Accel Platform セットアップガイド 第46版 2024-04-01

11.18.6.3. Apache POI 5.2.3 を利用している機能で Microsoft Office ファイル読み込み時にエラーとなる場合

  • IM-ContentsSearch のクローリングや、IM-LogicDesigner のユーザ定義タスク等 Apache POI 5.2.3 を利用している機能において、Microsoft Office ファイルの読み込みエラーが発生した場合の原因と対処方法を説明します。

11.18.6.3.1. 原因と対応方法

Apache POI 5.2.3 では読み込み時の最大テキストサイズ上限等がデフォルトで設定されているため、その値を超えるとエラーが出力されます。
intra-mart Accel Platform 2023 Autumn(Hollyhock)(Apache POI 5.2.3-PATCH_002) 以降のバージョンではシステムプロパティから上限値を設定できるようになりました。
エラー例を参考に下記システムプロパティを設定してください。
※大きなファイルを取り扱うリスクもご確認の上設定してください。
  • 設定可能なシステムプロパティ

    設定内容 プロパティ値
    レコード長の最大サイズ jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.byteArrayMax integer
    ファイル展開時の最大サイズ jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.maxEntrySize long
    最大テキストサイズ jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.maxTextSize long
    最小圧縮率 jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.minInflateRatio double

11.18.6.3.1.1. レコード長のサイズが上限を超過している場合

以下が対象ファイルのレコード長のサイズが上限を超過していた場合のエラー例です。
  • エラー例

    jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.util.RecordFormatException: Tried to allocate an array of length xxx,xxx,xxx, but the maximum length for this record type is xxx,xxx,xxx.
    If the file is not corrupt and not large, please open an issue on bugzilla to request
    increasing the maximum allowable size for this record type.
    You can set a higher override value with IOUtils.setByteArrayMaxOverride()
    

jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.byteArrayMax がレコード長のサイズ( ログの Tried to allocate an array of length xxx,xxx,xxx, )より大きくなるように設定します。
デフォルトの設定値は 100000000 です。
  • 設定例

    jvm_args : -Djp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.byteArrayMax=200000000
    

11.18.6.3.1.2. ファイル展開時のサイズが上限を超過している場合

以下が対象ファイルの展開サイズが上限を超過していた場合のエラー例です。
  • エラー例

    java.io.IOException: Zip bomb detected! The file would exceed the max size of the expanded data in the zip-file.
    This may indicates that the file is used to inflate memory usage and thus could pose a security risk.
    You can adjust this limit via ZipSecureFile.setMaxEntrySize() if you need to work with files which are very large.
    Uncompressed size: xxxxxxx, Raw/compressed size: xxxxxxx
    Limits: MAX_ENTRY_SIZE: xxxxxxx, Entry:xxxxxxx
    

jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.maxEntrySize がファイルの展開サイズ( ログの size: xxxxxxx )より大きくなるように設定します。
デフォルトの設定値は 4294967295 です。
  • 設定例

    jvm_args : -Djp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.maxEntrySize=4500000000
    

11.18.6.3.1.3. 抽出テキストサイズが上限を超過している場合

以下が対象ファイルの文字数が上限を超過していた場合のエラー例です。
  • エラー例

    java.lang.IllegalStateException: The text would exceed the max allowed overall size of extracted text. By default this is prevented as some documents may exhaust available memory and it may indicate that the file is used to inflate memory usage and thus could pose a security risk. You can adjust this limit via ZipSecureFile.setMaxTextSize() if you need to work with files which have a lot of text. Size: xxxxxxxxxx, limit: MAX_TEXT_SIZE: xxxxxxxxxx
    

jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.maxTextSize がファイルのテキストサイズ( ログの Size: xxxxxxxxxx )より大きくなるように設定します。
ログは MAX_TEXT_SIZE を超過したタイミングで出力されるため、実際のテキストサイズは Size: xxxxxxxxxx より大きい場合があります。
デフォルトの設定値は 10485760 です。
  • 設定例

    jvm_args : -Djp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.maxTextSize=20000000
    

11.18.6.3.1.4. 圧縮率が下限を下回る場合

以下が対象ファイルの圧縮率が最小圧縮率より小さい場合のエラー例です。
  • エラー例

    java.io.IOException: Zip bomb detected! The file would exceed the max. ratio of compressed file size to the size of the expanded data.
    This may indicate that the file is used to inflate memory usage and thus could pose a security risk.
    You can adjust this limit via ZipSecureFile.setMinInflateRatio() if you need to work with files which exceed this limit.
    Uncompressed size: xxxxxx, Raw/compressed size: xxxxx, ratio: x.xxxxxxxx
    Limits: MIN_INFLATE_RATIO: x.xxxxxxxx, Entry: xxxxxxx
    

jp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.minInflateRatio がファイルの圧縮率( ログの ratio: x.xxxxxxxx )より小さくなるように設定します。
デフォルトの設定値は 0.01 です。
  • 設定例

    jvm_args : -Djp.co.intra_mart.system.repackage.poi_5_2_3.org.apache.poi.minInflateRatio=0.001