3 Replies Latest reply: Jan 15, 2009 6:27 PM by 679826 RSS

    All factories fail for the operation "stream"

    679826
      Hi. I'm uploading an image file to a servlet and resizing it using this code. It's able to handle other JPG files; chokes on one image.
        public BufferedImage resizeImage(InputStream inputStream)
        {
          BufferedImage resizedImage = null;
          
            SeekableStream stream = SeekableStream.wrapInputStream(inputStream, false);
            RenderedOp newImage = JAI.create("stream",stream);
            ((OpImage)newImage.getRendering()).setTileCache(null);
            
            double scale = targetWidth / newImage.getWidth();
            
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(newImage);
            pb.add(scale);
            pb.add(scale);
            
            /*
             * For best results, must use the following rendering hints.
             */
            RenderingHints qualityHints = 
              new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            
            resizedImage = (JAI.create("SubsampleAverage",pb,qualityHints)).getAsBufferedImage();
      
          return resizedImage;
        }
      Error: One factory fails for the operation "stream"
      Occurs in: javax.media.jai.ThreadSafeOperationRegistry
      java.lang.reflect.InvocationTargetException
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:324)
           at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
           at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1682)
           at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
           at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
           at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:830)
           at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
           at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
           at org.unctv.util.ImageHandler.resizeImage(ImageHandler.java:120)
           at org.unctv.premiumautomation.UploadHandler.doPost(UploadHandler.java:218)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
           at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
           at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
           at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
           at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
           at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
           at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
           at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      ........
      Caused by: java.lang.IllegalArgumentException: src must support seeking backwards or marking.
           at com.sun.media.jai.codec.ImageCodec.getDecoderNames(ImageCodec.java:255)
           at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:80)
           ... 46 more