I was doing some testing with our app and noticed that if I removing an
ImageIO plugin's code from the classpath, but still include an entry for
the plugin's ImageReader in META-INF/services, I am no longer able to
use ANY of the ImageIO plugins.
I'm using JDK1.4.2_09. I get a NoClassDefFoundError upon running the
String names = ImageIO.getReaderFormatNames();
The reason I'm getting a
NoClassDefFoundError at this line is because of a failure in
the static initializer of the ImageIO class. It's calling the
IIORegistry, which is trying to iterate over the available
ImageReaders. Since I've removed the plugin code from the classpath,
the registry gets an error when trying to load the class for
the particular plugin.
This to me seems to be a serious problem. Failure of a single
plugin brings the whole ImageIO plugin system down. This puts
the plugin architecture at the mercy of any malicious or
careless developer who might misconfigure their plugin and
thus disable all other plugins.
Naturally, it would be nice to know when a single plugin has
failed to load, but it seems this error should be caught so
that other plugins could continue to load properly.
Here's the stack trace down to the point where it leaves our code
and goes into the J2SE code:
Provider com.lmco.imageio.nitf.NITFImageWriterSpi not found