title: javax.faces:jsf.js resource returns 404
body: <p>I currently use mojarra javax.faces-2.2.8.jar and Apache Tomcat 6.0.26 Server.</p>
  
  <p>I'm trying to add ajax behaviour to an input field(it's just for simplification).</p>
  
  <p>Here is the simple facelets page(welcome.xhtml):</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:al = "http://xmlns.jcp.org/jsf/composite/AppearanceLibrary" 
        xmlns:h = "http://xmlns.jcp.org/jsf/html" 
        xmlns:ui = "http://xmlns.jcp.org/jsf/facelets"
        xmlns:f = "http://xmlns.jcp.org/jsf/core"&gt;
      &lt;h:head/&gt;
      &lt;h:body&gt;
          &lt;h:form&gt;
              &lt;h:outputLabel for = "login" 
                         value = "login" /&gt;
              &lt;h:inputText id = "login" value = "#{authentication.submittedLogin}"&gt;
                  &lt;f:ajax execute = "login" render = "out" /&gt;
              &lt;/h:inputText&gt;
              &lt;h:outputText id = "out" value = "#{authentication.submittedLogin}" /&gt;
          &lt;/h:form&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the HTML output:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;head id="j_idt2"&gt;&lt;script type="text/javascript" src="/JSFCars/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&amp;amp;stage=Development"&gt;&lt;/script&gt;&lt;/head&gt;&lt;body&gt;
  &lt;form id="j_idt4" name="j_idt4" method="post" action="/JSFCars/welcome.xhtml" enctype="application/x-www-form-urlencoded"&gt;
  &lt;input type="hidden" name="j_idt4" value="j_idt4" /&gt;
  &lt;label for="j_idt4:login"&gt;login&lt;/label&gt;&lt;input id="j_idt4:login" type="text" name="j_idt4:login" onchange="mojarra.ab(this,event,'valueChange','j_idt4:login','j_idt4:out')" /&gt;&lt;span id="j_idt4:out"&gt;&lt;/span&gt;&lt;input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="o5U6o+AhXUBnlwlaf5BbfJsXNxEe0OmBn+vyQUuLH1If1Hk802YaE1PT+ACraIlE+2rJMXEMJcDEgtaxMDURnPR0EFkR0Pdln4WoUMimfPxwbiCQCQcPfL+JDsPkyx+S6SvffiRyQFmz40B/lF5qtnt+AzzGhkYyuiuokiZVnJYv4hZBVhImLwKLm28dGvVh9qfnpnjngXm8cmAdIVULAY1sn1koFC2Bv702uBK0z9I6jHzMQFdPPCpBd5b+rri7R952i9cfi/CYGdcFSCq1yZGYL0s7E5Dshgaaikr5MVdJ4pRRQbiF60hypro+ZLavymy7G2pMukJNRaMhr7SxZffK13rGuCfpBXzXwdSeXZp2tMpWBhXJZ8gk/7rYzizmMgOTssZtj1inrPAgJdMSu2CJM2Q1xMV5wQSmSpU3bSHWdGknSMH4EGZsipKf8YCr3EsOSPD9khK8hlT5AmLm/iQ0j1xRHJny/6mIPJjVPPN/nD6AXBY+9bdt+SUPEKpT4u8in5ZulcG57t/9NUq/VA==" autocomplete="off" /&gt;
  &lt;/form&gt;&lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my deployment descriptor:</p>
  
  <pre><code>&lt;?xml version = "1.0" encoding = "UTF-8"?&gt;
  &lt;web-app xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 
           xmlns = "http://xmlns.jcp.org/xml/ns/javaee" 
           xsi:schemaLocation = "http://xmlns.jcp.org/xml/ns/javaee 
                                 http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
           id = "WebApp_ID" 
           version = "3.1"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;
              javax.faces.STATE_SAVING_METHOD
          &lt;/param-name&gt;
          &lt;param-value&gt;
              client
          &lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;
              javax.servlet.jsp.jstl.fmt.localizationContext
          &lt;/param-name&gt;
          &lt;param-value&gt;
              resources.application
          &lt;/param-value&gt;
      &lt;/context-param&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;listener&gt;
          &lt;listener-class&gt;
              com.sun.faces.config.ConfigureListener
          &lt;/listener-class&gt;
        &lt;/listener&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;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/welcome.xhtml&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;welcome.xhtml&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Inside the browser's JavaScript console I got the message that this request <a href="http://localhost:8086/JSFCars/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&amp;stage=Development" rel="nofollow noreferrer">http://localhost:8086/JSFCars/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&amp;stage=Development</a> failed with 404(Not found). And as the result when I try to invoke the  input field's ajax behaviour I get the following message: Uncaught ReferenceError: mojarra is not defined.</p>
  
  <p>I'm aware that I should use <code>&lt;h:head&gt;</code> and <code>&lt;h:body&gt;</code>, otherwise the jsf.js wasn't included in first place. I've tried several browsers and the results were the same. Also I've tried the myfaces-core-2.0.2-bin jsf implementation.</p>
  
  <p>I has found very similar question <a href="https://stackoverflow.com/questions/9248047/clicking-hcommandlink-causes-uncaught-referenceerror-mojarra-is-not-defined">here.</a> The problem was connected with the user defined filter which rejected the js request. But I
   don't define any filters in the web deployment descriptor. Might there be any implicitly defined filter that blocks that request? Or are there any other ideas why something blocks that request?</p>
  
  <p>Since the time I asked this question I installed "GlassFish Server Open Source Edition  4.1.2" 
  server and deployed the application on it(I included "javax.faces-2.2.8.jar" into project libraries, 
  but I think the server uses the internal "Mojarra 2.2.14" JSF implementation). As the way of testing 
  of the JSF implementation I tried using a template, a composite componet. <code>&lt;ui:composition&gt;</code>, <code>&lt;ui:define&gt;</code> 
  tags and custom library inclusion work as needed. <code>authentication</code> bean is created and perfectly initialized using <code>faces-congig.xml</code>. Then after it I removed everything not related to 
  the question and left only <code>welcome.xhtml</code> page. Again I got "404 Not found".</p>
  
  <p>The solution is to remove everything connected to faces servlet from the <code>web.xml</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/3uo2U.jpg" rel="nofollow noreferrer">The view of the rendered <code>welcome.xhtml</code> page after applying the solution</a></p>