IllegalArgumentException : Width (-1) and height (-1) cannot be <=0
843807Aug 28 2003 — edited Mar 4 2009Hi,
A method which returns java.awt.Image as :
public Image getImage() {
String fileName = "/directory/some.jpg";
return (Toolkit.getDefaultToolkit().getImage(fileName);
}
throws following exception :
java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:250)
at com.sun.xml.messaging.saaj.soap.JpegDataContentHandler.writeTo(JpegDataContentHandler.java:129)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:849)
at javax.activation.DataHandler.writeTo(DataHandler.java:305)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:635)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:233)
at com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:372)
The method is exposed as a web service, and the server throws this error when the client is run. What else do I have to set to remove this error? I believe the width/height parameters are read from the jpg itself. Help is highly appreciated.