RandomOfAmbr
RandomOfAmbr

Reputation: 11

NoSuchFieldError: SIZE when fetching email through IMAP

We're using Java with Spring and Gradle, among other things, and lately after deploying to prod this error started coming up every time we tried to fetch messages from our MSExhange server. I'm baffled, as there were no changes made to the package which is responsible for the process.

There's the error...

java.lang.NoSuchFieldError: SIZE
    at com.sun.mail.imap.IMAPFolder.fetch(IMAPFolder.java:1200)

...which is called at the third line of that bit...

FetchProfile fetchProfile = new FetchProfile();
fetchProfile.add(ID_HEADER);
folder.fetch(messages, fetchProfile);

Here's the ImapFolder line 1200, which is yet another reason as to why I am completely baffled...

if (fp.contains(FetchProfile.Item.SIZE) ||

...because how in the world can such an exception be thrown while trying to access public static final field, I've no idea.

Thank you for reading this far. And in general.

Upvotes: 0

Views: 815

Answers (1)

RandomOfAmbr
RandomOfAmbr

Reputation: 11

The problem was solved as follows:

Gradle: org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.7.1 Looks like this lib has caused the aforementioned email problem as it contains old JavaxMail version - 1.4 instead of 1.5.6, which we used.

It was a transitive dependency of org.apache.cxf:cxf-rt-ws-security, which was found by making gradle print the whole dependency tree.

Upvotes: 1

Related Questions