JAI : how to solve vendorName == null exception

Hello everybody,

Have You ever used JAI (Java Advanced Imaging) ? If You used the class ImageIO in order to read and save images, the answer is yes.
Most of the time, You should not have problem when You deploy Your application with an executable JAR even if You’re using JAI. But, most of the time doesn’t mean never, so that’s a problem !
Recently I had to deploy an application as a JAR, and this application was using quantity of external library. And of course it used JAI.
Well, doing a JAR is not really a problem but …

In my case, the application was developped with Eclipse, and was running fine in it. But, when it comes to run it with a JAR, that was problematic…
I got an exception when a tried to load images, especially TIFF images. This exception was thrown by JAI and told me that the vendorName was null. Interessting : but which vendor ??

The answer is quiet simple : JAI needs sometimes to know the name of the vendor who developped the application, and the implementation of it… OK, you’ll tell me “Fine. It seems it’s my application, so I’m the vendor. But how do I specify that?”. And that’s the point.

When You deploy an application as an executable JAR, You probably know that You need a manifest file. And that manifest file is the key. A complete valid manifest file could be this :

Manifest-Version: 1.0
Main-Class: fr.free.thierrywasyl.myproject.launcher.Launch

But where did I specify the author? No where. But JAI will maybe need to know that, or You’ll get an exception about the vendor. So let’s add some lines, which are good to add (take it as a good practice) which are general:

Manifest-Version: 1.0
Implementation-Vendor: Sun Microsystems, Inc
Implementation-Title: Java Runtime Environment
Implementation-Version: 1.6.0
Main-Class: fr.free.thierrywasyl.myproject.launcher.Launch

So far so good. So are You a null vendor? Of course not, You get over the exception😉
Enjoy.

One Response to JAI : how to solve vendorName == null exception

  1. Hello!
    Great work. I read about this solution everywhere but you explaned the problem good. But it’s not work for me. I am still getting error. This is my stack:
    Exception in thread “Thread-7” Exception in thread “Thread-15” java.lang.NoClass
    DefFoundError: Could not initialize class javax.imageio.ImageIO
    at com.harmanbecker.preimport.tests.CheckImageSize.readImage(CheckImageS
    ize.java:96)
    at com.harmanbecker.preimport.tests.CheckImageSize.findImages(CheckImage
    Size.java:64)
    at com.harmanbecker.preimport.tests.CheckImageSize.executeTest(CheckImag
    eSize.java:82)
    at com.harmanbecker.rdt.utils.RawDataTest.run(RawDataTest.java:160)
    sun.misc.ServiceConfigurationError: javax.imageio.spi.ImageInputStreamSpi: Provi
    der com.sun.media.imageioimpl.stream.ChannelImageInputStreamSpi could not be ins
    tantiated: java.lang.IllegalArgumentException: vendorName == null!
    at sun.misc.Service.fail(Service.java:120)
    at sun.misc.Service.access$200(Service.java:111)
    at sun.misc.Service$LazyIterator.next(Service.java:276)
    at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIOReg
    istry.java:190)
    at javax.imageio.spi.IIORegistry.(IIORegistry.java:121)
    at javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:142
    )
    at javax.imageio.ImageIO.(ImageIO.java:48)
    at com.harmanbecker.rdt.utils.Checker.createImageFromFile(Checker.java:3
    43)
    at com.harmanbecker.rdt.utils.Checker.diffImages(Checker.java:141)
    at com.harmanbecker.rdt.utils.Checker.diff(Checker.java:116)
    at com.harmanbecker.preimport.tests.ImagesTest.executeTest(ImagesTest.ja
    va:84)
    at com.harmanbecker.rdt.utils.RawDataTest.run(RawDataTest.java:160)
    Caused by: java.lang.IllegalArgumentException: vendorName == null!
    at javax.imageio.spi.IIOServiceProvider.(IIOServiceProvider.java:5
    9)
    at javax.imageio.spi.ImageInputStreamSpi.(ImageInputStreamSpi.java
    :73)
    at com.sun.media.imageioimpl.stream.ChannelImageInputStreamSpi.(Ch
    annelImageInputStreamSpi.java:63)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at sun.misc.Service$LazyIterator.next(Service.java:271)
    … 9 more

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: