users@glassfish.java.net

Sporadic corruption of uploaded data to servlet

From: <glassfish_at_javadesktop.org>
Date: Sun, 21 Oct 2007 17:06:35 PDT

After two days of troubleshooting I am continuing to have problems where images I upload to a very simple servlet in glassfish appear to be corrupted. My program is a remote desktop utility which uses glassfish as a sort of proxy server.

As it stands now it simply repeatedly uploads PNG images via a http request post method along with 2 head parameters representing the x and y location of this image on the client desktop. Everything seems to work except that it appears that glassfish is sporadically corrupting my image data. To troubleshoot this i tried the following

1-before attempting to post each image to the server i wrote it to a file with a random name, upon inspection all files were able to open fine.

2-when the serlvet receives the entire image as a byte[] but before storing the image files in my server-side cache I attempted writing the files to a random file in a folder on my computer, it appears everything works fine. Upon inspection the largest files (aprox 5-6KB) are corrupted.

3-Since I knew my images were not corrupt at the time they are sent to the server I added two additional request parameters to my HTTP request for imagehashcode and image length by getting the hash of the data that was ACTUALLY RECEIVED along with the length of the byte array I would compare the hashcodes of the data meant to be sent and what was actually received along with the lengths. Interestingly the length of my imagedata before sending it to the server and after receiving it is the same but the hash is not.

I should note a few things,

I am running Sun Java System Application Server 9.1 (build b58g-fcs)

My client application is running JDK 1.5

I have used both the JDK's built in HttpURLConnection and the Apache Commons HttpClient and found both cause no change to my problem.

Perhaps I am also doing something fundamentally wrong, it was suggested by a friend that I should not be making an HTTP post request every time I upload a new image as remote desktop applications will send at least 5 images per second.

Any help is appreciated, this is a very frustrating problem to run into as it has halted all work for me over what seems should be trivial. Thanks!
[Message sent by forum member 'benju' (benju)]

http://forums.java.net/jive/thread.jspa?messageID=241418