Skip to main content

vendorName == null!

1 reply [Last post]
Joined: 2009-07-29

I am trying to extract the XMP metadata from TIFF headers as part of a larger application. While debugging and running unit tests everything works fine. However, when the application is included in a jar, I receive the following:

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(
Caused by: sun.misc.ServiceConfigurationError: javax.imageio.spi.ImageReaderSpi: Provider could not be instantiated: java.lang.IllegalArgumentException: vendorName == null!
at sun.misc.Service.access$200(
at sun.misc.Service$
at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(
at javax.imageio.spi.IIORegistry.(
at javax.imageio.spi.IIORegistry.getDefaultInstance(
at javax.imageio.ImageIO.(
at edu.princeton.diglib.Util.XMPExtrator.main(
... 5 more
Caused by: java.lang.IllegalArgumentException: vendorName == null!
at javax.imageio.spi.IIOServiceProvider.(
at javax.imageio.spi.ImageReaderWriterSpi.(
at javax.imageio.spi.ImageReaderSpi.(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at java.lang.Class.newInstance0(
at java.lang.Class.newInstance(
at sun.misc.Service$
... 10 more

"vandorName == null!" is what jumps out at me. I'm relatively new to Java, and completely new to the JAI classes. Here's a summary a what my code does:

package edu.princeton.diglib.Util;

import java.util.Iterator;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.metadata.IIOMetadata;


public class MdExtrator {
public static void main(String[] args) throws IOException {

ImageInputStream iis = null;
iis = ImageIO.createImageInputStream(new File("/path/to/a.tif"));

Iterator readers;
readers = ImageIO.getImageReadersByMIMEType("image/tiff");
ImageReader image = (ImageReader);

IIOMetadata md = image.getImageMetadata(0);
TIFFDirectory tiffDir = TIFFDirectory.createFromMetadata(md);
String xmp = new String(tiffDir.getTIFFField(700).getAsBytes());
xmp = xmp.replaceAll("<\\?.*\\?>", "").trim();



Any help would be greatly appreciated!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-03-08

I'm troubleshooting something similar, in my case related to trying to use the jai_imageio plugins from inside Eclipse. I can probably at least get you started.

The stack trace indicates that a subclass of ImageReaderSpi is trying to instantiate itself with a vendor name set to null. This is clearly a no-no from the ImageReaderSpi javadoc. I ended up using the often useful web site to track this down. The site has what looks like the source code for all classes in the JDK. It is clearly not the real source code, and I'm not sure if it is reverse engineered from the binaries, or is based on some kind of open source clone. (I'm sure it's easy to find out where it comes from, but I've never been curious enough to try to find out).

Anyway, the class in question is CLibJPEGImageReaderSpi (presumably because this is the first one found), so I looked at java2s's page on this classes source code, found here:

It's clear enough that this class is instantiating itself by invoking super(...), which is ImageReaderSpi(...), with the value of PackageUtil.getVendor() passed in as the value of vendor.

Now, I had a slight advantage over you, because I'm using Eclipse, and in Eclipse the scan process employed by ImageIO API to discover SPIs doesn't happen automatically, I had to trigger it. This gave me the opportunity to peek into what PackageUtil.getVendor() is returning, and in my case it is indeed null. So this sent me back to java2s.

Although not in the code, referenced classes in the source code are helpfully linked from their import statements. The import statement for PackageUtil links you to the source code for that module at:

It gets a little confusing here because in this code, getVendor() returns a string constant, so it should never be null. Fortunately, for reasons I don't understand, there's a comment in this code which contradicts the code itself. It says that the vendor name is discovered from the manifest.

Now in my case, because I had unbundled the API and rebundled it as an Eclipse plugin, Eclipse replace the original manifest information with it's own. When I opened the manifest file and added back in the manifest information Eclipse had stripped out, I found that PackageUtil.getVendor() did in fact return the value in the manifest file, and the remainder of the process completed without any trouble.

Here is the stuff I added to the manifest file to get it to work:

Specification-Title: Java Advanced Imaging Image I/O Tools
Specification-Version: 1.0-mr
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Version: 1.0_01
Implementation-Vendor: Sun Microsystems, Inc.

Like I said, I can't solve your problem because your environment differs from mine. My guess would be that for whatever reason, the jar file containing your jai_imageio is missing this information in the META-INF/MANIFEST.MF file, or is missing the manifest altogether. It's at least someplace to start looking. Good luck.