Search code examples
javajquerywebtomcat7centos6.5

ERR_CONTENT_LENGTH_MISMATCH while loading js files on tomcat server


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.

Solution

  • 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.