Link that points to an URL with an image returns an error

I create a Link that points sets its resource to an external resource that is a GIF.

On some images, I get an error:

The image “http:…” cannot be displayed, because it contains errors.

What might cause this? I can open the same image directly in a web browser. And I can open it using Paint Shop Pro, for example.

But I tried to load that image’s data into a Java ImageIcon and it also reports MediaTracker.ERROR.

Is there some limitation in Java for dealing with Images?

Also, it seems that the Link ends up calling the URL 2-3 times. Is that normal?

These no doubt are Vaadin issues, but maybe someone has seen this too? Very odd to me…

It’s hard to say what could be the problem. There’s a link to an image in
this example
, but I don’t see any problems with it. The URL is called just once, it seems.

Perhaps the file extension is wrong so that the content type is determined badly - some image viewers and editors don’t really care about the extension and detect the content type differently so the image would show just OK in them, but not in a browser or with another viewer. If the image is an external resource, this probably isn’t a Vaadin problem. Check if they work from a static web page.

I had been serving the image from my own webapp’s database via a servlet, so I tweaked the code to instead set a fixed URL, which is also the image that for whatever reason, I cannot display from my database no matter how many times I upload it, whereas all other images are fine.

https://esignforms.com/NationalDebtAdjusters/images/nationaldebtLogo.gif

At any rate, in the ‘access log’ of the other web server, it is clear that is called twice (in this case, not using any of my Vaadin code to serve the image) – and of course the Link then opens a window and shows the image fine, without any error about it being invalid:

98.111.70.237 - - [28/Jan/2011:09:17:22 -0800]
“GET /NationalDebtAdjusters/images/nationaldebtLogo.gif HTTP/1.1” 200 15076 “http://localhost/open-eSignFormsVaadin/vaadin/” “Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13”
98.111.70.237 - - [28/Jan/2011:09:17:22 -0800]
“GET /NationalDebtAdjusters/images/nationaldebtLogo.gif HTTP/1.1” 200 15076 “-” “Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13”

When it’s not hacked, it goes to my servlet, and my breakpoint shows it’s being called twice. I also can see that after the first call’s response, the Link that opens the window and shows the image already has it shown, so the second call is not doing anything. The debug stack trace at the breakpoint in my servlet is identical for both calls, too.

But I have since found that this ONLY occurs with Firefox, and when I use IE8, Safari, Chrome or Opera, the image is only requested once. I don’t know what odd setting I have for FF that is causing this, or if all FF does this, but it is odd and is clearly not a Vaadin issue.

As for the invalid image file, I cannot figure it out, but I am pretty sure it’s not a Vaadin issue. I capture the file using the Upload component and store it “as is.” But I also pass it to a javax.swing.ImageIcon where I can then scale it for a thumbnail, and that code is the one that says the image is invalid. If I save the GIF as a JPEG using Paint Shop Pro, the JPEG can be used, but when I save it as a PNG, it gets the same invalid image error. The image is not particularly interesting (big or small or odd dimensions or anything), and most every other image works just fine. I’m guessing this is not a Vaadin issue either, but if I figure anything out, I’ll let the forum know.

The GIF image problem may be related to this bug report in Java:


http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6517427

Java is throwing this exception dealing with the data uploaded (which I have confirmed is the correct length and at least starts and ends on the same bytes, so I think the upload is fine):

javax.imageio.IIOException: Unexpected block type 249!

Sadly, I had hoped it might be fixed in 6u23, but it may only be in 7b10. At this point, I’m just going to live with it… If I convert them to JPEG or PNG, they seem to get fixed and can be read. Rats on those GIFs and Java for having bugs in their code on a GIF Version 89a standard.

Your GIF URL https://esignforms.com/NationalDebtAdjusters/images/nationaldebtLogo.gif shows just fine for me with Ubuntu Firefox 3.6.12.

But yeah, this doesn’t sound like a Vaadin problem, unless Vaadin upload for example truncates files or upload streams somehow. But it doesn’t sound like that.

It turns out this is a Vaadin upload bug…


http://dev.vaadin.com/ticket/6361