0

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.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Sounds like a serious library mismatch/compile issue. – Max Dec 02 '16 at 18:13
  • 2
    You've probably got multiple versions of the JavaMail classes on your classpath. Check every jar file for javax.mail and com.sun.mail classes; they should only be in one jar file. Especially make sure you don't have javaee.jar on your classpath. – Bill Shannon Dec 04 '16 at 04:39

1 Answers1

1

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.