3

Configuration:

  • OS: CntOS 6.5 minimal
  • Tomcat: 7.0.53
  • Deployed war file contains many .js and .css files

Issue: When the war file is deployed on tomcat, it gets exploded properly and the web portal works fine. Machine is idle for over 12 hours.

  • I access tomcat page: works fine. Even the manager page opens fine.
  • I launch my webportal, it does not load. Error: GET http://:8080/webportal/client/libs/jquery/jquery-ui-1.9.2.min.js net::ERR_CONTENT_LENGTH_MISMATCH 10.211.106.184/:63 I get this error for various other js files as well.

What i have tried:

  • Not an issue with memory since sufficient memory is available.
  • Tried to open the .js file in another tab, the page keeps loading for a long time and then stops loading. The file is not fully downloaded. Hence the content mismatch issue.
  • Access to the same url from the local CentOS box using wget works but access from browser on remote box does not
  • Once static file is accessed on appliance using vi editor (not saved only accessed), downloads from browser start working

Question:

  • What could possibly be an issue here? Is there any compatibility issue with tomcat and CentOS.
  • Note again that immediately after deployment everything works fine. Webportal does not work only after a few (>12 approx) hours of inactivity.
  • Must be a content length limit/restriction in your web server settings. – Control Freak Sep 24 '14 at 09:16
  • Thanks Zee. However, the content length issue is because the loading of webpage stops before download of js file is complete. And this does work after the war is deployed. Only stops working if server is idle for 12 hours or more. – Dhaval Metrani Sep 24 '14 at 11:13

3 Answers3

3

In conf/server.xml config file in apache tomcat folder set the "usesendfile" attribute to "false" as shown below:-

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"  **useSendfile="false"**/>

Please refer to link: http://ci.apache.org/projects/tomcat/tomcat7/docs/config/http.html for more details.

KunalLaud
  • 46
  • 3
  • Thanks Kunal. Setting `usesendfile=false` would ensure that tomcat sends compressed responses and hence reducing the time required for transfer on slower networks. The has fixed the issue. – Dhaval Metrani Nov 28 '14 at 08:24
  • @DhavalMetrani I don't think your conclusion ist correct. Setting usesendfile=false turns off compression and thus save cpu time. – Marc Johnen Nov 30 '16 at 11:30
1

Since this is the first Google hit for the query "tomcat" net::ERR_CONTENT_LENGTH_MISMATCH, I'll share what I did in my case to solve the problem. For me, the jsp pages in the application loaded normally, but some CSS and JS files (e.g. jQuery) failed to load, exactly with this net::ERR_CONTENT_LENGTH_MISMATCH error.

This happened after I had set the timeout parameter of the Tomcat server to -1, as described here:

connectionTimeout
The number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. Use a value of -1 to indicate no (i.e. infinite) timeout.

It's in the server.xml file in the conf folder. Setting this to another value (60000) solved the problem for me.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • Thanks Glorfindel for the answer. It's been over 4 years since I posted this! Out of curiosity, does this work with any other timeout value? And did you have to wait for 12 hours before getting this error? – Dhaval Metrani Apr 23 '19 at 01:59
  • The timeout value used to be 20000 and that worked too. I'm not sure if I needed to wait for 12 hours, I think restarting Tomcat already applied the new timeout settings. – Glorfindel Apr 23 '19 at 06:57
0

Try to deploy your webapp to Tomcat 6 or Tomcat 8, sometimes it works. I have solved such a issue but I don't know why. So you can have a try. Maybe it works. Good luck!

malajisi
  • 2,165
  • 1
  • 22
  • 18