简体   繁体   中英

Apache-tika 1.23 fails .eml file as an attachment to email throws NoClassDefFoundError

java.lang.NoClassDefFoundError: org/apache/james/mime4j/stream/MimeConfig$Builder 
at org.apache.tika.parser.mail.RFC822Parser.parse(RFC822Parser.java:74)
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:280)
at org.apache.tika.parser.ParserDecorator.parse(ParserDecorator.java:188)
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:280)
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:280)
at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:143)
at org.apache.tika.Tika.parseToString(Tika.java:527)
at org.apache.tika.Tika.parseToString(Tika.java:602)

When trying to parse the body content from.eml file using Apache Tika throws NoClassDefFoundError.

AutoDetectParser identifies it as RFC822Parser to be used, however, in the parse method of RFC822Parser it tries to build the MimeConfig

MimeConfig config = new MimeConfig.Builder()
                .setMaxLineLen(100000)
                .setMaxHeaderLen(100000)
                .build();

Unable to construct the instance and breaks.

Actually, I figured the problem as to why RFC822Parser failing to create an instance of MimeConfig because there was a conflict between two Apache libraries -> Apache Tika and Apache James Jdkim library. Both have the same class name MimeConfig but different behavior and loading equivalent class Runtime go haywire

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM