I have encountered a problem with the ImageTools plugin when deploying my Grails app (as a war). Or maybe not with the plugin per se, but with the JAI package. This is the error:
2011-01-23 18:48:48,412 [TP-Processor16] [tenant N/A] ERROR errors.GrailsExceptionResolver - Encode No ImageEncoder is available for this format or this image cannot be encoded with the given encoding parameters.
java.lang.IllegalArgumentException: Encode No ImageEncoder is available for this format or this image cannot be encoded with the given encoding parameters.
at javax.media.jai.JAI.createNS(JAI.java:1087)
at javax.media.jai.JAI.create(JAI.java:973)
at javax.media.jai.JAI.create(JAI.java:1668)
at javax.media.jai.JAI$create$1.call(Unknown Source)
at org.grails.plugins.imagetools.ImageTool.getBytes(ImageTool.groovy:146)
at org.grails.plugins.imagetools.ImageTool$getBytes.call(Unknown Source)
at nl.gentleware.zzpadm.DocumentController$_closure15.doCall(DocumentController.groovy:578)
at nl.gentleware.zzpadm.DocumentController$_closure15.doCall(DocumentController.groovy)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:774)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:896)
at java.lang.Thread.run(Thread.java:662)
// resize the image, if necessary
def imageTool = new ImageTool()
imageTool.load(content)
imageTool.thumbnailSpecial(350,50,1,1)
// set imageTool contentType
def imageToolContentType
if (contentType == 'image/gif') {
imageToolContentType = 'GIF'
}
else if (contentType == 'image/png') {
imageToolContentType = 'PNG'
}
else {
imageToolContentType = 'JPEG'
}
// upload the file
docId = documentService.saveAccountDocument(fileName,contentType,'ACCOUNT_LOGO',imageTool.getBytes(imageToolContentType),true)
The strange thing is, the exception does NOT occur on my development environment (Windows7) and also NOT on my test environment (Ubuntu/Tomcat), but only on my production environment... This is the technology stack on my production server:
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
apache-tomcat-6.0.29.tar.gz
Server version: Apache/2.2.3
Server built: Aug 30 2010 12:28:40