0
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.

  • 1
    Welcome to Stack Overflow. Please take the [tour](https://stackoverflow.com/tour), read about [what's on-topic](https://stackoverflow.com/help/on-topic), and read [How to Ask a Good Question](https://stackoverflow.com/help/how-to-ask). From [Why am I getting a NoClassDefFoundError in Java?](https://stackoverflow.com/a/5756989/5698098) you should check for other errors; with the given information it isn't very likely that others can help you effectively ([reproducible example?](https://stackoverflow.com/help/minimal-reproducible-example)). – Ivo Mori Jul 27 '20 at 02:25
  • How did you go about adding Apache Tika to your classpath? What steps did you take to ensure all the dependencies of Apache Tika are present at runtime? – Gagravarr Jul 27 '20 at 05:30
  • Using maven had added tika dependencies like to the classpath. How to ensure it is added properly? I could parse Mail with attachments like another zip, xlsx, txt, pdf, html, pptx etc. However, when I am trying to extract from a mail with the attachment of .eml it is unable to construct the RFC822Parser. – Shaik Rizwan Jul 28 '20 at 05:06
  • 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. – Shaik Rizwan Sep 02 '20 at 23:09

1 Answers1

0

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