title: Get PrimeFaces JSF working on Tomcat
body: <p>I am trying to get a PrimeFaces <a href="http://www.primefaces.org/showcase/ui/fileUploadMultiple.jsf" rel="nofollow noreferrer">multiple file uploader</a> working on a JSF page and have been given the following requirements (non-negotiable!) by my tech lead:</p>
  <ul>
  <li>Must be a PrimeFaces/JSF page called <code>imageUpload.jsf</code></li>
  <li>Must deploy to a WAR and deployed on Tomcat (<code>v7.0.19</code>)</li>
  <li>Must use the following PrimeFaces/JSF JARs (they're &quot;enterprise architecture standards&quot;): <code>jsf-api.jar</code> and <code>jsf-impl.jar</code> from JSF 2.0.3, and <code>primefaces-2.2.1.jar</code></li>
  </ul>
  <p>My first task is to just replicate what that linked demo page has - just a simple JSF page that contains the file upload component on it. So I created an Eclipse project, created what I <em>believe</em> to be the correct directory structure and configuration files, used Ant to WAR it up, and deployed to Tomcat's webapps directory. <strong>When I go to <code>localhost:8080/imageUpload.jsf</code>, I get a 404 (The requested resource (/imageUpload.jsf) is not available.) error.</strong></p>
  <p>Here's my setup:</p>
  <p>Project directory structure in eclipse:</p>
  <pre><code>ImageUploader
      src/
          com.company.imgupload.FileUploadController.java
      build/ --&gt; where java compiles to and then copies over to WEB-INF/classes/
      dist/ --&gt; where image-uploader.war gets WARed to
      lib/ --&gt; copied to WEB-INF/lib/
      war/
          META-INF/
              MANIFEST.MF
          WEB-INF/
              classes/
              lib/
              imageUpload.xhtml
              faces-config.xml
              web.xml
  </code></pre>
  <p>The <code>FileUploadController.java</code> is the same as what the PrimeFaces people have on the demo link provided above - again I'm just trying to get this simple example working before I start to customize it for what we need.</p>
  <p><code>web.xml</code>:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;web-app version=&quot;2.5&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; &gt;
      &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;imageUpload.jsf&lt;/welcome-file&gt;
      &lt;/welcome-file-list&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;*.jsf&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  <p><code>faces-config.xml</code>:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;faces-config xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd&quot; version=&quot;2.0&quot;&gt;
      &lt;!-- Not using MangedBean declarations for this simple example --&gt;
  &lt;/faces-config&gt;
  </code></pre>
  <p><code>imageUpload.xhtml</code>:</p>
  <pre><code>&lt;html xmlns=&quot;http://www.w3c.org/1999/xhtml&quot; xmlns:f=&quot;http://java.sun.com/jsf/core&quot; xmlns:h=&quot;http://java.sun.com/jsf/html&quot; xmlns:p=&quot;http://primefaces.prime.com.tr/ui&quot;&gt;
  &lt;h:head&gt;
      &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;themes/bluesky/skin.css&quot; /&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
      &lt;center&gt;
      &lt;p:panel header=&quot;Multiple File Uploader Demo&quot; style=&quot;width: 350;&quot;&gt;
      &lt;h:form enctype=&quot;multipart/form-data&quot;&gt;
          &lt;p:fileUpload fileUploadListener=&quot;#{fileUploadController.handleFileUpload}&quot;   mode=&quot;advanced&quot; update=&quot;messages&quot; multiple=&quot;true&quot; sizeLimit=&quot;100000&quot; allowTypes=&quot;/(\.|\/)(gif|jpe?g|png)$/&quot;/&gt;
          &lt;p:growl id=&quot;messages&quot; showDetail=&quot;true&quot;/&gt;
      &lt;/h:form&gt;
      &lt;/p:panel&gt;
      &lt;div&gt;&lt;h:messages &gt;&lt;/h:messages&gt;&lt;/div&gt;
      &lt;/center&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>For reiteration, these are placed in the following WAR file:</p>
  <pre><code>image-uploader.war/
      META-INF/
          MANFIEST.MF
      WEB-INF/
          classes/
              com/company/imgupload/FileUploadController.java
          lib/
              jsf-api.jar (v2.0.3)
              jsf-impl.jar (v2.0.3)
              primefaces-2.2.1.jar
          web.xml
          faces-config.xml
          imageUpload.xhtml
  </code></pre>
  <p>This war is then deployed to <code>${CATALINA.HOME}/webapps/</code>. When I run Tomcat, I don't get any errors or warnings in the logs, but I do see this in <code>catalina.&lt;date&gt;.log</code> (I'm on Windows 7):</p>
  <blockquote>
  <p>Apr 11, 2012 2:31:33 PM org.apache.catalina.startup.HostConfig deployWAR</p>
  <p>INFO: Deploying web application archive image-uploader.war</p>
  <p>Apr 11, 2012 2:31:34 PM com.sun.faces.config.ConfigureListener contextInitialized</p>
  <p>INFO: Initializing Mojarra 2.0.3 (FCS b03) for context '/image-uploader'</p>
  <p>Apr 11, 2012 2:31:34 PM com.sun.faces.spi.InjectionProviderFactory createInstance</p>
  <p>INFO: JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.</p>
  </blockquote>
  <p>Am I missing any other configuration files here? Do I need to have a <code>imageUpload.jsf</code> on top of (or instead of) <code>imageUpload.xhtml</code>?</p>
  <p><strong>What explains this 404 error I'm getting?!?</strong> Thanks in advance.</p>
  <p><strong>NOTE:</strong> Unless it is <em>impossible</em> to get PrimeFaces/JSF working under the JAR versions I've indicated, please just respect that I don't have any say-so over what our standards are. If I can prove that JSF 2.0.3 is incompatible with PrimeFaces 2.2.1, then I can probably convince the technical brass to change standards. But unless I can prove that, these are the versions and technologies I'm stuck with - so <em>please</em> don't clutter SO with &quot;<em>why would you choose that technology</em>&quot;- or &quot;<em>why would you use an old version</em>&quot;-type responses!</p>
  <p><strong>Edit</strong>:</p>
  <p>Changed my <code>web.xml</code> to reflect @Luigi's suggestion, and (per @Matt's suggestion) pointed my browser at <code>localhost:8080/image-uploader/imageUploader.jsf</code> and am not getting an HTTP 500 error:</p>
  <pre><code>SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/image-uploader] threw exception [javax/servlet/jsp/jstl/core/Config] with root cause
  java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
  at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:340)
  at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:150)
  ...etc.
  </code></pre>
  <p>Does this mean anything to anyone?</p>