How to register twelvemonkey.imageIO into java servicemix registery

1.4k views Asked by At

Error:

javax.imageio.IIOException - Unsupported Image Type]
javax.imageio.IIOException: Unsupported Image Type
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:977)[:1.6.0_26]
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:948)[:1.6.0_26]
    at javax.imageio.ImageIO.read(ImageIO.java:1422)[:1.6.0_26]
    at javax.imageio.ImageIO.read(ImageIO.java:1374)[:1.6.0_26]
    at com.brodos.test.ScaleImage.execute(ScaleImage.java:23)[914:testproject:1.0.0.SNAPSHOT]
    at com.brodos.test.TestProcessor.process(TestProcessor.java:57)[914:testproject:1.0.0.SNAPSHOT]
    at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[89:org.apache.camel.camel-core:2.8.0.fuse-02-05]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-02-05]
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[89:org.apache.camel.camel-core:2.8.0.fuse-02-05]
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[89:org.apache.camel.camel-core:2.8.0.fuse-02-05]
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-02-05].

I have already added jars to my maven project and dependencies into my pom.xml file as per the below comments

2

There are 2 answers

0
Dhaval Patel On

I think you need to manually register plugins to be used with ImageIO in servicemix. But you have to make sure that plugins are available in class path for the servicemix bundle.

ImageIO.scanForPlugins();
0
shahjenu On
soultions found was  :
First Approach :
1)  use the TwelveMonkeys library https://github.com/haraldk/TwelveMonkeys/

2) before making Image to be read or write as imageIo.read or imageIo.write scan for plugin using  ImageIO.scanForPlugins()  and add the twelvemonkeys lib. as maven depedency.

maven install :

osgi:install -s wrap:mvn:com.twelvemonkeys.imageio/imageio-jpeg/3.0

osgi:install -s wrap:mvn:com.twelvemonkeys.imageio/imageio-core/3.0

osgi:install -s wrap:mvn:com.twelvemonkeys.imageio/imageio-metadata/3.0

osgi:install -s wrap:mvn:com.twelvemonkeys.imageio/imageio-batik/3.0

osgi:install -s wrap:mvn:com.twelvemonkeys.imageio/imageio-jmagick/3.0

osgi:install -s wrap:mvn:batik/batik-1.5-fop/0.20-5



<Import-Package>
    batik;resolution:=optional,
    magick;resolution:=optional,
    bsh;resolution:=optional,
    com.twelvemonkeys.*,
    *
</Import-Package>
<Export-Package>
    com.twelvemonkeys.*,
    com.google.gson.*,
    com.brodos.common.*,
</Export-Package>
<DynamicImport-Package>*</DynamicImport-Package>
<Embed-Dependency>imageio-jpeg,imageio-core,imageio-metadata,imageio.batik,imageio.jmagick;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>


Second Approach : Endorsed Mechanism
1) Add the TwelveMonkeys into servicemix /lib/endorsed directory  and the execute the application.