bbottema / outlook-message-parser

A Java parser for Outlook messages (.msg files)
76 stars 35 forks source link

Re: MimeType NoClassDefFoundError #62

Open weiliang2 opened 1 year ago

weiliang2 commented 1 year ago

Hi there,

I am facing a issue with the error below the email looks normal but with just a pdf attachement.

is there any advise how should i show the error log?

java.lang.NoClassDefFoundError: Could not initialize class org.simplejavamail.outlookmessageparser.model.MimeType at org.simplejavamail.outlookmessageparser.model.OutlookFileAttachment.checkMimeTag(OutlookFileAttachment.java:100) ~[outlook-message-parser-1.9.6.jar:na] at org.simplejavamail.outlookmessageparser.OutlookMessageParser.parseAttachment(OutlookMessageParser.java:676) ~[outlook-message-parser-1.9.6.jar:na] at org.simplejavamail.outlookmessageparser.OutlookMessageParser.checkDirectoryEntry(OutlookMessageParser.java:224) ~[outlook-message-parser-1.9.6.jar:na] at org.simplejavamail.outlookmessageparser.OutlookMessageParser.parseMsg(OutlookMessageParser.java:138) ~[outlook-message-parser-1.9.6.jar:na]

weiliang2 commented 1 year ago

The core dependencies are:

org.slf4j:slf4j-api com.sun.mail:jakarta.mail com.sun.activation:jakarta.activation jakarta.xml.bind:jakarta.xml.bind-api jakarta.annotation:jakarta.annotation-api com.sanctionco.jmail:jmail (address validation) com.pivovarit:throwing-function (improved Streams api)

bbottema commented 1 year ago

It seems you posted half of the stacktrace. Where's the 'caused by'?

gregorycollins commented 1 year ago

We are having the same issue. The issue is the static section in MimeTypes:

    private static final MimetypesFileTypeMap MIMETYPES_FILE_TYPE_MAP = createMap();

    /**
     * @return a vastly improved mimetype map
     */
    private static MimetypesFileTypeMap createMap() {
        try (InputStream is = MimeType.class.getClassLoader().getResourceAsStream("mimetypes.txt")) {
            return new MimetypesFileTypeMap(is);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }

MimeType.class.getClassLoader().getResourceAsStream("mimetypes.txt") must not be retrieving the resource in our environment -- we build our binaries with Bazel.

gregorycollins commented 1 year ago

...and to follow up, our font of definitely-not-ChatGPT-generated wisdom Stack Overflow has an explanation of the issue. I will send a patch

gregorycollins commented 1 year ago

https://github.com/bbottema/outlook-message-parser/pull/63

bbottema commented 1 year ago

Let's discuss the PR.