dotCMS thumbnail error: java.lang.IncompatibleClassChangeError
In our dotCMS 1.7 environments, we found - on just one environment (PROD, of all places!) - that image thumbnails were broken. For example, referencing the image itself worked fine:
In the logs, I noticed the below error.
I reported this issue on the dotCMS Yahoo group here: Thumbnails not showing - java.lang.IncompatibleClassChangeError. In a response to that post, Maria Ahues Bouza noted that dotCMS only supports Sun Java (Oracle now I guess) as it's defined on their technology requirements page.
http://example.com/path/to/image.jpg
, but referencing the thumbnail fails: http://example.com/thumbnail?inode=60732&w=75&h=50
.In the logs, I noticed the below error.
[07/03/11 04:39:53:053 EST] ERROR [/].[ThumbnailServlet]: Servlet.service() for servlet ThumbnailServlet threw exception java.lang.IncompatibleClassChangeError: Found class com.sun.image.codec.jpeg.JPEGImageEncoder, but interface was expected at com.dotmarketing.util.Thumbnail.resizeImage(Thumbnail.java:114) at com.dotmarketing.servlets.image.ThumbnailImage.service(ThumbnailImage.java:203) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.dotmarketing.filters.CMSFilter.doFilter(CMSFilter.java:104) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)After some Googling, I found the below description of the error on this page: 'Interface was expected' for JPEGImageEncoder.
Root CauseI then confirmed that PROD did indeed have a different JRE than the other environments. On DEV:
If you found this error appears in the log file, the biggest possibility and maybe the only reason that this exception being thrown is you are using the OpenJDK instead of Sun JDK. Well, the exception message is obvious to tell you that the com.sun.image.codec.jpeg.JPEGImageEncoder is a class in OpenJDK whereas it is implemented as an interface in Sun JDK.
java -version java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b06) Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)But on PROD:
java -version java version "1.6.0_17" OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-x86_64) OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)So... we had the wrong JDK. Overnight, we installed Java HotSpot on PROD, changed PATH and JAVA_HOME to point to the new JRA, and the issue was resolved.
I reported this issue on the dotCMS Yahoo group here: Thumbnails not showing - java.lang.IncompatibleClassChangeError. In a response to that post, Maria Ahues Bouza noted that dotCMS only supports Sun Java (Oracle now I guess) as it's defined on their technology requirements page.