java.lang.NoSuchMethodError: org.springframework.http.MediaType.getCharset()Ljava/nio/charset/Charset

Unbelievable...foiled by class loading issues once again...an uber jar named activemq-minimal-5.13.3.jar had references to spring jars in it that was causing the conflict. activemq-minimal-5.13.3.jar comes before spring alphabetically so the classes in that activemq jar were being loaded/used over the spring jars. Updated my ant build to load the spring classes first and now I'm all set.

The way I found out is I put all of my 3rd party libs together in a "Test" project and added/deleted jars (with somewhat of an inclination where the problem was) until I was able to pinpoint where the class loading issue was.


org.springframework.http.MediaType.getCharset() was introduced since 4.3 if java did not find it that mean that you have a spring-core version below 4.3.1 in your classpath which get loaded and used.


In spring latest version they have modified

org.springframework.http;

MediaType contentType = headers.getContentType();

Old :

      contentType.getCharSet()

New :

     contentType.getCharset()