I'm completely stumped. I'll give the background for the sake of completeness but I'm not sure if it will help or not. I'm running a Lift project on a standard Jetty set-up running one Lift instance. Mac OS X.
I have a snippet which transforms the XML input, renders an image, saves it to disc under the webroot/images/ directory with a filenametaken from the MD5 of the contents, such as "c5669d3eedcf7d305dcf9f88a61b3ee0.png". The snippet then returns an img tag with a reference to the generated image for inclusion in the output.
Most of the time most of the images work. But most of the time some of them don't, and some of the images are not rendered by the browser. Attempting to view a problem image in the browser (Camino and Firefox) doesn't work: the image is not displayed, suggesting that something is vaguely wrong.
Viewing it in another browser (Safari and with QuickTime), the image works fine. Downloading and opening the image works fine. When viewing the file directly with Camino (i.e. file://...), the image shows fine: the file itself is not obviously corrupted.
It can't be the length of the filename, because all filenames are the same 37 characters.
I can only assume that something goes wrong in the transport of the image when served through Jetty.
The URIs that do fail, fail consistently, it's not intermittent. Restarting Jetty makes no difference, so I don't think it's that the file was created after the server started. Also, the render is a blocking call, so there's no chance that the file is still open / hasn't been saved before the HTML is sent and the browser requests the images.
The only thing I can imagine is that the MIME type is mangled, so I put the appropriate mapping in web.xml but still no cigar. The MIME type looks to be OK and I've verified that the number of bytes is correct.
For the problem image:
HTTP/1.1 200 OK Expires: Thu, 01 Jan 1970 00:00:00 GMT Set-Cookie: JSESSIONID=1dbeh8eq4mtu0;Path=/ Content-Type: image/png Content-Length: 25488 Last-Modified: Sat, 25 Jul 2009 15:38:19 GMT Server: Jetty(6.1.16)
For completeness, the headers from an image that does load fine:
HTTP/1.1 200 OK Expires: Thu, 01 Jan 1970 00:00:00 GMT Set-Cookie: JSESSIONID=15dt649lzovc4;Path=/ Content-Type: image/png Content-Length: 18657 Last-Modified: Sat, 25 Jul 2009 15:41:35 GMT Server: Jetty(6.1.16)
Very very puzzled about this. Any clues?
Cheers
Joe