title: Java ImageIO suddenly stops working on Tomcat 7
body: <p>We have a servlet running under tomcat 7 that converts stored TIFF images into JPEGs for display in a web application using the Java Advanced Imaging libraries. This servlet has been working since 2011. Recently, however, it has started to fail in a very odd location. We can read the TIFF image in no problem but when we try to write the result of the conversion out to a cache file, our call to ImageIO.createImageOutputStream starts returning null. </p>
  
  <p>I have been unable to find any errors in the tomcat logs that correspond to when this stops working. Restarting tomcat seems to temporarily resolve the issue, but it appears to be happening with more frequency. To my knowledge we have made no changes to java, tomcat or the code running in this servlet recently. We have the JAI libraries in tomcat's lib folder rather than the web application. What could be causing this library to suddenly start failing during the day?</p>
  
  <p>Relevant code section:</p>
  
  <pre><code>//Get a JPEG writer and write the converted image to the output stream
          ImageWriter writer = null;
          Iterator&lt;ImageWriter&gt; writers = ImageIO.getImageWritersByMIMEType("image/jpeg");
  
          if(writers.hasNext()){
              writer = writers.next();
          } else {
              System.out.println("No JPEG Writer!");
              return;
          }
  
          FileOutputStream fos = new FileOutputStream(cacheFile);
          ios = ImageIO.createImageOutputStream(fos); //This is what is returning null
          writer.setOutput(ios);
          writer.write(resizedImage);
          fos.close();
  </code></pre>