3

I have problem with my tomcat application, after changing the server and installing the last version of tomcat7 my application won't read/load jpg files..

I installed imageio and jai on the server, try to change java version but every time I have the same error..

Anybody have an idea?

Error: One factory fails for the operation "jpeg" 
Occurs in: javax.media.jai.ThreadSafeOperationRegistry 
java.lang.reflect.InvocationTargetException 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:606) 
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122) 
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674) 
        at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473) 
        at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332) 
        at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:102) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:606) 
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122) 
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674) 
        at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473) 
        at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332) 
        at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819) 
        at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867) 
        at javax.media.jai.RenderedOp.getWidth(RenderedOp.java:2179) 

The whole error log can be found here -> http://paste.ubuntu.com/7653452/.

Update: The problem is related to grails plugin called ImageTools

elacheche
  • 71
  • 2
  • 10
  • Please post the whole error message – Max Meijer Jun 11 '14 at 14:55
  • what version of java? what version of imageio? – Brett Okken Jun 11 '14 at 15:14
  • @brett-okken: I tried OpenJDK6 and OpenJDK7, and Oracle JDK6 and OracleJDK7.. ImageIO → libgtlimageio0.8 – elacheche Jun 16 '14 at 15:11
  • @max_meijer: The whole log → http://paste.ubuntu.com/7653452/ – elacheche Jun 16 '14 at 15:14
  • 1
    Caused by: java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/ImageFormatException you have a classloading problem. Some jar is missing or needs to be in tomcat/lib probably – Karl Kildén Jun 17 '14 at 10:11
  • @karl-kildén I already added the sun-jai_codec.jar to my project lib dir and to java lib dir :/ but I have the same error.. :/ – elacheche Jun 18 '14 at 09:54
  • Last time I used Tomcat, the libs should be in `shared/lib`, alternatively, you could place them in your JRE's `ext/lib` folder. – Harald K Jun 19 '14 at 20:01
  • @haraldK I added them to `/usr/lib/jvm/java-6-openjdk-common/jre/lib/ext/` and create links `ln -s /usr/lib/jvm/java-6-openjdk-common/jre/lib/ext/*jai*.jar /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/ext/` restarted tomcat tested jpeg import.. same error :( – elacheche Jun 20 '14 at 09:19
  • Have you verified that the JAR is ok, and contains the classes in question? – Harald K Jun 20 '14 at 09:20
  • Using `jarsigner -verify file.jat` it says `jar is unsigned. (signatures missing or not parsable)` for all jars :/ – elacheche Jun 20 '14 at 09:27
  • Still have the same problem.. I installed grails on the server but I have the same problem, the problem came from ImageTools plugin. Anyone have an alternative to ImageTools Plugin?! The developer don't offer support for it any more.. And am getting problems with it when I moved to a new server and new Java version.. – elacheche Jul 04 '14 at 10:41

1 Answers1

4

If you look at the code for JPEGImageDecoder you'll see it depends on com.sun.image.codec.jpeg.ImageFormatException in its imports.

However, com.sun.image.codec.jpeg was removed from Java 7 onwards.

So likely the problem is that JAI is simply out of date, and you would have to use a Java 6 runtime to use it.

Community
  • 1
  • 1
Dan Gravell
  • 7,855
  • 7
  • 41
  • 64