Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullpointer Exception when reading CMYK (Servlet) #21

Closed
mercutiodesign opened this issue Nov 28, 2013 · 4 comments
Closed

Nullpointer Exception when reading CMYK (Servlet) #21

mercutiodesign opened this issue Nov 28, 2013 · 4 comments

Comments

@mercutiodesign
Copy link

Based on the latest version of this github repository (running java 1.6.0_16 and Debian 4.1.2-25). I build the project with maven and then added

twelvemonkeys-common-lang-3.0-SNAPSHOT.jar
twelvemonkeys-common-io-3.0-SNAPSHOT.jar
twelvemonkeys-common-image-3.0-SNAPSHOT.jar
twelvemonkeys-imageio-core-3.0-SNAPSHOT.jar
twelvemonkeys-imageio-metadata-3.0-SNAPSHOT.jar
twelvemonkeys-imageio-jpeg-3.0-SNAPSHOT.jar
twelvemonkeys-imageio-tiff-3.0-SNAPSHOT.jar
twelvemonkeys-servlet-3.0-SNAPSHOT.jar

to my servlet libs. I'm trying to read any CMYK image, for example:

Channel digital image CMYK color

From Wikipedia. The same image is loaded if I just run a test locally.
As a servlet, I get the following NullPointerException:

java.lang.NullPointerException
    at com.twelvemonkeys.imageio.color.ColorSpaces.getColorSpace(ColorSpaces.java:265)
    at com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader.getImageTypes(JPEGImageReader.java:232)
    at com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader.readImageAsRasterAndReplaceColorProfile(JPEGImageReader.java:351)
    at com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:337)
    at javax.imageio.ImageIO.read(ImageIO.java:1422)
    ...

It seems really odd, that this line would cause a NPE, as the code in com.twelvemonkeys.imageio.color.ColorSpaces just reads:

profile = genericCMYK.get();

and the genericCMYK is a static variable:

private static WeakReference<ICC_Profile> genericCMYK = new WeakReference<ICC_Profile>(null);

that does not seem to be nulled anywhere.

@mercutiodesign
Copy link
Author

A restart of the server fixed the issue.
For anyone stumbling across this in the future, make sure you do not just redeploy your war files over and over but actually restart the tomcat server.
Very sorry for the inconvenience.

@haraldk
Copy link
Owner

haraldk commented Nov 29, 2013

Hi!

Thanks for reporting (and debugging it).

Just a quick question: Did you do as described in the readme about deploying the plugins in a web app? I'm curious, as this is one of the problems that the IIOProviderContextListener is supposed to fix. You shouldn't have to restart your tomcat server for each redeploy.

Anyway, happy to hear you made it work! :-)

Best regards,

Harald K

@mercutiodesign
Copy link
Author

Hi,

Yes, I actually followed the README and added the listener to the web-app xml file.
ImageIO.read(…) correctly used the twelvemonkeys classes to load the jpg so at least some part worked correctly.
I don't know what the problem was but if it doesn't come back I'm writing this one off as a random problem in tomcat / our deployment.

Thanks for your interest,

Martin D.

@haraldk
Copy link
Owner

haraldk commented Dec 4, 2013

Ok, I'm happy to leave it at that for now. :-)

Harald K

@haraldk haraldk added the Bug label Mar 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants