Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IllegalArgumentException : Width (-1) and height (-1) cannot be <=0

843807Aug 28 2003 — edited Mar 4 2009
Hi,
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.


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2009
Added on Aug 28 2003
3 comments
891 views