troubleshooting Question

Help with javax.imageio.ImageIO.write problem getting java.lang.IllegalArgumentException:

Avatar of lasanac
lasanac asked on
JavaJava EE
11 Comments1 Solution4857 ViewsLast Modified:
I am getting this error when I try to write my tiff to disk.  I get the file from an e-mail attachment.  It is not null but when I read it in, but when I do an ImageIO.read(inputStream) it is null after that.  Not sure what is going on here, but it is very confusing.  Any help would be great.  

Here is the full stack trace:

 
java.lang.IllegalArgumentException: im == null!
      at javax.imageio.ImageIO.write(Unknown Source)
      at javax.imageio.ImageIO.write(Unknown Source)
      at org.mule.example.email.EmailRetriever.mail(EmailRetriever.java:114)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.mule.model.resolvers.AbstractEntryPointResolver.invokeMethod(AbstractEntryPointResolver.java:147)
      at org.mule.model.resolvers.ReflectionEntryPointResolver.invoke(ReflectionEntryPointResolver.java:178)
      at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:50)
      at org.mule.component.DefaultLifecycleAdapter.intercept(DefaultLifecycleAdapter.java:202)
      at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:82)
      at org.mule.component.AbstractJavaComponent.doOnCall(AbstractJavaComponent.java:73)
      at org.mule.component.AbstractComponent.onCall(AbstractComponent.java:87)
      at org.mule.model.seda.SedaService$ComponentStageWorker.run(SedaService.java:533)
      at org.mule.work.WorkerContext.run(WorkerContext.java:310)
      at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
      at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
      at java.lang.Thread.run(Unknown Source)

String attContentType = handler.getContentType();
		            System.out.println("Some Data " + attContentType);
		            File f = new File("c:\\TempMail" + dte + ".tif");
		            if(attContentType.startsWith("image/")){
		            	//TIFFWriter writer = new TIFFWriter();
		            	//java.awt.image.BufferedImage [] images  = new java.awt.image.BufferedImage[2];
		            	
		            	//images [0] = writer.getBufferedImageFromImage(ImageIO.read(handler.getInputStream()));
		            	InputStream input = handler.getInputStream();
		            	System.out.println("help Ako: " +input.available());
		            	java.awt.image.BufferedImage im = ImageIO.read(input);
		            	System.out.println("help: ");
		            	ImageIO.write(ImageIO.read(input), "tiff", f);
		            	//writer.createTIFFFromImages(images , f);
		            	System.out.println("hello");
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros