title: Primefaces adds .xhtml extention to css and .js files when rendered so styles and JavaScript don't work
body: <p>I try to create a webApp using Primefaces 4.0 and spring 3.2.5 for Dependency injection.</p>
  
  <p>Primefaces dependencies:</p>
  
  <pre><code>    &lt;!-- primefaces and jsf --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
          &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
          &lt;version&gt;${primafaces.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.primefaces.themes&lt;/groupId&gt;
          &lt;artifactId&gt;blitzer&lt;/artifactId&gt;
          &lt;version&gt;1.0.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.primefaces.themes&lt;/groupId&gt;
          &lt;artifactId&gt;home&lt;/artifactId&gt;
          &lt;version&gt;1.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
          &lt;version&gt;2.1.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
          &lt;version&gt;2.1.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>This is the login page:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui"&gt;
  
  &lt;h:head&gt;
      &lt;h:outputScript library="js" name="mainPageHelper.js" /&gt;
  
      &lt;h:outputStylesheet name="login-page.css" library="css" /&gt;
  &lt;/h:head&gt;
  
  &lt;h:body onload="checkErrorStatus();"&gt;
  
  &lt;h:form id="f" styleClass="f" name="f" method="POST"&gt;
  
      &lt;h:outputText styleClass="error" style="color:red; display:none; background-color:     #C2DFFF"&gt;given username and/or password incorrect&lt;/h:outputText&gt;
  
      &lt;h:outputText&gt;Log in&lt;/h:outputText&gt;
  
      &lt;h:panelGrid id="grid" columns="3" cellpadding="4"&gt;
  
          &lt;p:outputLabel value="Username:" /&gt;
          &lt;p:inputText id="username" name="j_username" required="true" requiredMessage="Username is required" size="25" style="width:120px;" /&gt;
          &lt;p:message for="username"/&gt;
  
          &lt;h:outputLabel value="Password:" /&gt;
          &lt;h:inputSecret id="password" name="j_password" required="true" requiredMessage="Password is required" style="width:120px;" size="25" /&gt;
          &lt;p:message for="password"/&gt;
  
          &lt;p:commandButton id="loginRedirect" value="Login" action="#{loginController.loginRedirect}" ajax="false" /&gt;
      &lt;/h:panelGrid&gt;
  &lt;/h:form&gt;
  
  &lt;/h:body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>As you can see, I am trying to import my own styling and my own Javascript. The resources are found, but when the page is created, an <strong>.xhtml</strong> extension is added to each file, even to the primefaces javascript and css, as seen below:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
       &lt;link type="text/css" rel="stylesheet" href="/ePIBWebApp/javax.faces.resource/theme.css.xhtml?ln=primefaces-home"&gt;
       &lt;link type="text/css"  rel="stylesheet" href="/ePIBWebApp/javax.faces.resource/login- page.css.xhtml?ln=css"&gt;
       &lt;link   type="text/css" rel="stylesheet" href="/ePIBWebApp/javax.faces.resource/primefaces.css.xhtml?ln=primefaces&amp;amp;v=4.0"&gt;
       &lt;script type="text/javascript" src="/ePIBWebApp/javax.faces.resource/jquery/jquery.js.xhtml?
  ln=primefaces&amp;amp;v=4.0"&gt;&lt;/script&gt;
       &lt;style type="text/css"&gt;&lt;/style&gt;
       &lt;script type="text/javascript" src="/ePIBWebApp/javax.faces.resource/primefaces.js.xhtml?ln=primefaces&amp;amp;v=4.0"&gt;&lt;/script&gt;
       &lt;script type="text/javascript" src="/ePIBWebApp/javax.faces.resource/mainPageHelper.js.xhtml?ln=js"&gt;&lt;/script&gt;
  &lt;/head&gt;
   &lt;body onload="checkErrorStatus();"&gt;
   &lt;form id="f" name="f" method="post" action="/ePIBWebApp/pages/login.xhtml" class="f"   enctype="application/x-www-form-urlencoded"&gt;
   &lt;input type="hidden" name="f" value="f"&gt;
   &lt;span class="error" style="color:red; display:none; background-color: #C2DFFF"&gt;&lt;/span&gt;&lt;table  id="f:grid" cellpadding="4"&gt;
   &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;label id="f:j_idt12" class="ui-outputlabel ui-widget"&gt;Username:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input id="f:username" name="f:username" type="text" size="25" style="width:120px;"  class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all"&gt;&lt;script id="f:username_s" type="text/javascript"&gt;PrimeFaces.cw('InputText','widget_f_username',{id:'f:username'});&lt;/script&gt;   &lt;/td&gt;
   &lt;td&gt;&lt;div id="f:j_idt13" aria-live="polite" class="ui-message"&gt;&lt;/div&gt;&lt;/td&gt;
   &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;label&gt;
  Password:&lt;/label&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input id="f:password" type="password" name="f:password" value="" size="25"      style="width:120px;"&gt;&lt;/td&gt;
   &lt;td&gt;&lt;div id="f:j_idt15" aria-live="polite" class="ui-message"&gt;&lt;/div&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;&lt;button id="f:loginRedirect" name="f:loginRedirect" class="ui-button ui-widget ui-state-  default ui-corner-all ui-button-text-only" type="submit"&gt;
   &lt;span class="ui-button-text ui-c"&gt;Login&lt;/span&gt;&lt;/button&gt;&lt;script id="f:loginRedirect_s"  type="text/javascript"&gt;PrimeFaces.cw('CommandButton','widget_f_loginRedirect', {id:'f:loginRedirect'});&lt;/script&gt;&lt;/td&gt;
   &lt;/tr&gt;
  &lt;/tbody&gt;
   &lt;/table&gt;
  &lt;input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState"  value="4305835440482722754:-5118499173786020406" autocomplete="off"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>The web.xml is the following:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
  &lt;display-name&gt;Hello world web application using PrimeFaces and Spring&lt;/display-name&gt;
  
  &lt;!-- Spring Context Configuration' s Path definitions --&gt;
  &lt;context-param&gt;
        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
        &lt;param-value&gt;
          /WEB-INF/applicationContext.xml
          /WEB-INF/spring-security.xml
        &lt;/param-value&gt;
   &lt;/context-param&gt;
  
    &lt;!-- The Bootstrap listener to start up and shut down Spring's root WebApplicationContext. 
          It is registered to Servlet Container --&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
     &lt;/listener&gt;
     &lt;listener&gt;
          &lt;listener-class&gt;
              org.springframework.web.context.request.RequestContextListener
          &lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Project Stage Level --&gt;
      &lt;context-param&gt;
              &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
          &lt;param-value&gt;Development&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Spring Security tag library for JSF --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.FACELETS_LIBRARIES&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/springsecurity.taglib.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
       &lt;!-- Welcome Page --&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;/index.xhtml&lt;/welcome-file&gt;
       &lt;/welcome-file-list&gt;
  
       &lt;!-- Spring Security filter Chain --&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;!-- Filter Mappings --&gt;
       &lt;filter-mapping&gt;
           &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
           &lt;url-pattern&gt;/*&lt;/url-pattern&gt; 
           &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
           &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
       &lt;/filter-mapping&gt;
  
      &lt;!-- JSF Servlet is defined to container --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
       &lt;!-- Mapping with servlet and url for the http requests. --&gt;
      &lt;servlet-mapping&gt;
           &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.faces&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;log4jConfig.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;com.sun.faces.enableMissingResourceLibraryDetection&lt;/param-name&gt;
           &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
           &lt;param-name&gt;primefaces.THEME&lt;/param-name&gt;
          &lt;param-value&gt;home&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.CONFIG_FILES&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/faces-config.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- 
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt;
          &lt;param-value&gt;.xhtml&lt;/param-value&gt;
      &lt;/context-param&gt;
      --&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;css&lt;/extension&gt;
          &lt;mime-type&gt;text/css&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;js&lt;/extension&gt;
          &lt;mime-type&gt;text/javascript&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;txt&lt;/extension&gt;
          &lt;mime-type&gt;text/plain&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;gif&lt;/extension&gt;
          &lt;mime-type&gt;image/gif&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;jpeg&lt;/extension&gt;
          &lt;mime-type&gt;image/jpeg&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;jpg&lt;/extension&gt;
          &lt;mime-type&gt;image/jpeg&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;png&lt;/extension&gt;
          &lt;mime-type&gt;image/png&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;xml&lt;/extension&gt;
          &lt;mime-type&gt;application/xml&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>security works.. I can log in with the credentials. I don't know what I did wrong in the configuration or why the .xhtml extension is added.</p>
  
  <p>Any ideas are appreciated.</p>