Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tapestry Web App on Tomcat occasionally spits out garbage

We have a Tapestry-Spring-Hibernate webapp running on Tomcat 6, handing about a few 1000 requests a second. Randomly, for no apparent reason, a page just displays a bunch of random characters on the browser. However, when the page is refreshed, it displays fine. Here is a screen-shot of the source of the garbled page on Chrome:

Page from tomcat on Chrome

Here is what I have found so far:

  1. It doesn't seem to be browser specific. I have witnessed this on Chrome and Firefox, but users have also reported this on IE 7 and up.
  2. Load on the server seems to have no correlation to when this happens.
  3. Refreshing the page displays the page normally, as if nothing ever happened.
  4. I don't see anything relevant in the server or the application logs
  5. The content-type tag for the page is <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
  6. There are a couple other webapps deployed on the same container, one being Alfresco, but they don't seem to exhibit this at all.

My question is, has someone run into this before, and if so, can they point me to where I should start looking? Is this a problem with the page having something like the incorrect content-type or the server not being able to handle it for some reason? Or could this be a framework bug in Tapestry or in the application itself? Any pointers are welcome. At this point, I am not sure where the problem is, so I wasn't sure if this goes on ServerFault or stays here.

like image 551
Jeshurun Avatar asked May 23 '12 13:05

Jeshurun


2 Answers

It is most likely a bug in the application. (Most bugs are ... despite the natural tendency of programmers to blame something else.)

However, could be a bit tricky to track down this problem. I suggest that you start with the standard things:

  • Look at the server error logs to see if anything strange shows up at the time when one of these "events" occur.
  • Look at the server access logs to see if you can identify the request that produced the garbage data.
  • Enable your browser's debugger and see if you can track down the bad request that way.

If you can figure out what the request that produced the bad response was, you'll have more traction in finding the cause.


FWIW - that doesn't look like the result of a character encoding problem. That looks more like binary or compressed data.

like image 72
Stephen C Avatar answered Nov 11 '22 05:11

Stephen C


Here's one situation that has led me to see a garbled page. On the error page Tapestry sets a response header called X-Tapestry-ErrorMessage. Evidently newlines aren't allowed in headers (at least on some browsers) so if that header has a newline in it, you get the gibberish. One error message we were setting happened to have a trailing new line. I changed it to remove any newlines before setting that header and then the error page showed correctly.

like image 39
Brian Deterling Avatar answered Nov 11 '22 05:11

Brian Deterling