1 Reply Latest reply on Apr 9, 2014 5:49 AM by Dotun Kola-Olaleye

    MIME Type Mismatch - JBoss AS 7.0

    Elliott Sang Newbie

      It appears that for some reason my server is specifying the wrong content-type for scripts and stylesheets. An example of a HTML script tag I use would be:

      <script type="text/javascript" src="script.js"></script>

       

      Chrome will return the following warnings:

      • Resource interpreted as Stylesheet but transferred with MIME type text/plain.
      • Resource interpreted as Script but transferred with MIME type text/plain.

       

      After doing some research it seemed that all I needed to do was add a "mime-mapping" to my web.xml, but this failed to resolve the issue. I tried adding:

      <mime-mapping>

                <extension>css</extension>

                <mime-type>text/css</mime-type>

      </mime-mapping>

      <mime-mapping>

                <extension>js</extension>

                <mime-type>application/x-javascript</mime-type>

      </mime-mapping>

       

      This is especially concerning because IE9 in standards mode will exclude the stylesheet (SEC7133: CSS was ignored due to mime type mismatch).

       

      ---

       

      Have other people been experiencing the same issue and has anyone discovered a solution? Thank you.

        • 1. Re: MIME Type Mismatch - JBoss AS 7.0
          Dotun Kola-Olaleye Newbie

          I know this is old, but someone might come looking just like I did... before I discovered the reason.

           

          Apparently, protection offered by the <security-contstraint> tag of web.xml causes everything that matches the pattern specified in the <url-pattern> to be served as text/html from the server. So, if scripts and css are served from a url that matches the pattern, they'll be sent as text/html.

           

          Try placing resources such as those outside the url pattern and that should solve the problem.