Recent Changes - Search:

edit SideBar

JAI

Ptolemy II uses Java Advanced Imaging (JAI).

JAI 1.1.3 was downloaded with

  wget http://download.java.net/media/jai/builds/release/1_1_3/jai-1_1_3-lib-linux-amd64.tar.gz

Under JDK 12, some of the tests fail.

  $PTII/bin/vergil  -v $PTII/ptolemy/actor/lib/jai/test/auto/JAIImageReader.xml

fails with:

javax.media.jai.util.ImagingException: All factories fail for the operation "stream"
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
        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.getRendering(RenderedOp.java:888)
        at ptolemy.actor.lib.jai.JAIImageReader.fire(JAIImageReader.java:156)
        at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:512)
        at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:216)
        at ptolemy.domains.sdf.kernel.SDFDirector.fire(SDFDirector.java:500)
        at ptolemy.actor.CompositeActor.fire(CompositeActor.java:455)
        at ptolemy.actor.Manager.iterate(Manager.java:851)
        at ptolemy.actor.Manager.execute(Manager.java:369)
        at ptolemy.actor.Manager.run(Manager.java:1263)
        at ptolemy.actor.Manager$PtolemyRunThread.run(Manager.java:1915)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
        ... 14 more
Caused by: javax.media.jai.util.ImagingException: All factories fail for the operation "jpeg"
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
        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)
        ... 20 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
        ... 23 more
Caused by: java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/ImageFormatException
        at com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(JPEGImageDecoder.java:46)
        at com.sun.media.jai.opimage.CodecRIFUtil.create(CodecRIFUtil.java:88)
        at com.sun.media.jai.opimage.JPEGRIF.create(JPEGRIF.java:43)
        ... 29 more
Caused by: java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.ImageFormatException
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 32 more
Caused by:
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        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.getRendering(RenderedOp.java:888)
        at ptolemy.actor.lib.jai.JAIImageReader.fire(JAIImageReader.java:156)
        at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:512)
        at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:216)
        at ptolemy.domains.sdf.kernel.SDFDirector.fire(SDFDirector.java:500)
        at ptolemy.actor.CompositeActor.fire(CompositeActor.java:455)
        at ptolemy.actor.Manager.iterate(Manager.java:851)
        at ptolemy.actor.Manager.execute(Manager.java:369)
        at ptolemy.actor.Manager.run(Manager.java:1263)
        at ptolemy.actor.Manager$PtolemyRunThread.run(Manager.java:1915)
Caused by: javax.media.jai.util.ImagingException: All factories fail for the operation "jpeg"
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
        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)
        ... 20 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
        ... 23 more
Caused by: java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/ImageFormatException
        at com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(JPEGImageDecoder.java:46)
        at com.sun.media.jai.opimage.CodecRIFUtil.create(CodecRIFUtil.java:88)
        at com.sun.media.jai.opimage.JPEGRIF.create(JPEGRIF.java:43)
        ... 29 more
Caused by: java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.ImageFormatException
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 32 more

Note that com.sun.image.codec.jpeg.ImageFormatException is not found

Which classes are removed in Java 9? (StackOverflow)

See JDK 9 Release Notes Removed APIs, Features, and Options:

"client-libs/2d Remove the com.sun.image.codec.jpeg package com.sun.image.codec.jpeg has been shipped as a non-standard API since JDK 1.2. It was always advertised as a stop-gap measure until a proper standard equivalent was provided. That replacement (javax.imageio) has been there since JDK 1.4. As a result JDK 9 finally removes the long deprecated com.sun.image.codec.jpeg API which has been flagged as intended for removal for several releases. Applications which still depend on it will need to be re-coded in order to run on JDK9. See JDK-8038838"

javax.media.jai.util.ImagingException: All factories fail for the operation "stream"

Compiling jai-core

Using JDK 12 to compile https://github.com/mauricio/jai-core fails with lots of messages like:

[javac] /home/cxh/src/jai-core/src/share/classes/com/sun/media/jai/codecimpl/JPEGImageDec\
oder.java:29: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.ImageFormatException;
[javac] ^
[javac] /home/cxh/src/jai-core/src/share/classes/com/sun/media/jai/codecimpl/JPEGImageEnc\
oder.java:35: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGQTable;
[javac] ^
[javac] /home/cxh/src/jai-core/src/share/classes/com/sun/media/jai/codecimpl/JPEGImageEnc\
oder.java:36: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGDecodeParam;
[javac] ^
[javac] /home/cxh/src/jai-core/src/share/classes/com/sun/media/jai/codecimpl/JPEGImageEnc\
oder.java:68: error: package com.sun.image.codec.jpeg does not exist
[javac] com.sun.image.codec.jpeg.JPEGEncodeParam j2dEP,
[javac] ^
[javac] /home/cxh/src/jai-core/src/share/classes/com/sun/media/jai/codecimpl/TIFFImage.ja\
va:53: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGCodec;

Switching to Java 1.8 also fails because

    [javac] /home/cxh/src/jai-core/src/share/classes/com/sun/media/jai/codecimpl/JPEGImageDecoder.java:29: error: package com.sun.image.codec.jpeg does not exist
    [javac] import com.sun.image.codec.jpeg.ImageFormatException;

Solution: add this to build.xml (See Bug 206774 - [JDK 7] package com.sun.image.codec.jpeg does not exist and import com.sun.image.codec.jpeg.*)

 <compilerarg value="-XDignore.symbol.file"/>

Compiling, installing and rebuilding

  ant
  mkdir -p $PTII/vendors/jai-1_1_4/lib
  mkdir $PTII/vendors/jai-1_1_4/lib
  cp ./build/linux-amd64/debug/lib/ext/*.jar !$
  export JAVA_HOME=/usr/lib/jvm/java-12-oracle
  export PATH=${PTII}/bin:${JAVA_HOME}/bin:${PATH}
  cd $PTII
  ./configure

fails with:

javax.media.jai.util.ImagingException: All factories fail for the operation "stream"
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
        at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
        at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:333)
        at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:820)
        at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
        at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:888)
        at ptolemy.actor.lib.jai.JAIImageReader.fire(JAIImageReader.java:156)
        at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:512)
        at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:216)
        at ptolemy.domains.sdf.kernel.SDFDirector.fire(SDFDirector.java:500)
        at ptolemy.actor.CompositeActor.fire(CompositeActor.java:455)
        at ptolemy.actor.Manager.iterate(Manager.java:851)
        at ptolemy.actor.Manager.execute(Manager.java:369)
        at ptolemy.actor.Manager.run(Manager.java:1263)
        at ptolemy.actor.Manager$PtolemyRunThread.run(Manager.java:1915)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
        ... 14 more
Caused by: javax.media.jai.util.ImagingException: All factories fail for the operation "jpeg"
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
        at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
        at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:333)
        at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:102)
        ... 20 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
        ... 23 more
Caused by: java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/JPEGCodec
        at com.sun.media.jai.codecimpl.JPEGImage.<init>(JPEGImageDecoder.java:107)
        at com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(JPEGImageDecoder.java:46)
        at com.sun.media.jai.opimage.CodecRIFUtil.create(CodecRIFUtil.java:88)
        at com.sun.media.jai.opimage.JPEGRIF.create(JPEGRIF.java:43)
        ... 29 more
Caused by: java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.JPEGCodec
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 33 more
Caused by:
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        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:333)
        at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:820)
        at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
        at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:888)
        at ptolemy.actor.lib.jai.JAIImageReader.fire(JAIImageReader.java:156)
        at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:512)
        at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:216)
        at ptolemy.domains.sdf.kernel.SDFDirector.fire(SDFDirector.java:500)
        at ptolemy.actor.CompositeActor.fire(CompositeActor.java:455)
        at ptolemy.actor.Manager.iterate(Manager.java:851)
        at ptolemy.actor.Manager.execute(Manager.java:369)
        at ptolemy.actor.Manager.run(Manager.java:1263)
        at ptolemy.actor.Manager$PtolemyRunThread.run(Manager.java:1915)
Caused by: javax.media.jai.util.ImagingException: All factories fail for the operation "jpeg"
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
        at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
        at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:333)
        at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:102)
        ... 20 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
        ... 23 more
Caused by: java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/JPEGCodec
        at com.sun.media.jai.codecimpl.JPEGImage.<init>(JPEGImageDecoder.java:107)
        at com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(JPEGImageDecoder.java:46)
        at com.sun.media.jai.opimage.CodecRIFUtil.create(CodecRIFUtil.java:88)
        at com.sun.media.jai.opimage.JPEGRIF.create(JPEGRIF.java:43)
        ... 29 more
Caused by: java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.JPEGCodec
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 33 more

The problem above is that JDK 12 does not include the classes that were removed in Java 9.

Replacing JAI

  • Replace JAI (geotools)
  • jai-imageio-core - "a community fork of the original java.net project jai-imageio-core (which is no longer available upstream). ... The implementations provided by this project use the package name com.github.jaiimageio, note that other implementations might be provided by your Java installation or other dependencies. ... This project is called 'standalone' as unlike the original jai-imageio-core it has removed dependencies to jai-core packages (javax.media.jai) and JPEG 2000 (jj2000). This version also does not include the C implementations from libJIIO, meaning that this version is platform independent and fully redistributable under the 3-clause BSD license in LICENSE.txt (and thus is Apache and GPL compatible)."
  • [https://blog.idrsolutions.com/2012/05/replacing-the-deprecated-java-jpeg-classes-for-java-7/ Replacing the deprecated Java JPEG classes for Java 7]
Edit - History - Print - Recent Changes - Search
Page last modified on July 14, 2019, at 04:58 pm