Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you're facing a "weird" exception suggesting that classes/methods/files/components/tags are absent or different while they are seemingly explicitly included in the web application such as the ones below,</p> <blockquote> <p>java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet</p> </blockquote> <p></p> <blockquote> <p>java.util.MissingResourceException: Can't find javax.faces.LogStrings bundle</p> </blockquote> <p></p> <blockquote> <p>com.sun.faces.vendor.WebContainerInjectionProvider cannot be cast to com.sun.faces.spi.InjectionProvider</p> </blockquote> <p></p> <blockquote> <p>com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED</p> </blockquote> <p></p> <blockquote> <p>The tag named inputFile from namespace http:&#x2f;/xmlns.jcp.org/jsf/html has a null handler-class defined.</p> </blockquote> <p></p> <blockquote> <p>java.lang.NullPointerException at javax.faces.CurrentThreadToServletContext.getFallbackFactory</p> </blockquote> <p></p> <blockquote> <p>java.lang.AbstractMethodError at javax.faces.application.ViewHandlerWrapper.getWebsocketURL</p> </blockquote> <p>or when you're facing "weird" runtime behavior such as broken HTTP sessions (<code>jsessionid</code> appears in link URLs over all place), and/or broken JSF view scope (it behaves as request scoped), and/or broken CSS/JS/image resources, then the chance is big that the webapp's runtime classpath is polluted with duplicate different versioned JAR files.</p> <p>In your specific case with the <code>ClassFormatError</code> on the <code>FacesServlet</code>, it means that the JAR file containing the mentioned class has been found for the first time is actually a "blueprint" API JAR file, intented for implementation vendors (such as developers working for Mojarra and MyFaces). It contains class files with only class and method signatures, without any code bodies and resource files. That's exactly what "absent code attribute" means. It's purely intented for javadocs and compilation.</p> <h2>Always mark server-provided libraries as <code>provided</code></h2> <p>All dependencies marked "<a href="http://mvnrepository.com/open-source/java-specs" rel="nofollow noreferrer">Java Specifications</a>" in Maven and having <code>-api</code> suffix in the artifact ID are those blueprint APIs. You should absolutely not have them in the runtime classpath. You should always mark them <code>&lt;scope&gt;provided&lt;/scope&gt;</code> if you really need to have it in your pom. A well known example is the <a href="http://mvnrepository.com/artifact/javax/javaee-web-api" rel="nofollow noreferrer">Java EE (Web) API</a>:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;javax&lt;/groupId&gt; &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt; &lt;version&gt;&lt;!-- 6.0 or 7.0 or newer --&gt;&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; </code></pre> <p>If the <code>provided</code> scope is absent, then this JAR will end up in webapp's <code>/WEB-INF/lib</code>, causing all trouble you're facing now. This JAR also contains the blueprint class of <code>FacesServlet</code>.</p> <p>In your specific case, you have an unnecessary <a href="http://mvnrepository.com/artifact/javax.faces/javax.faces-api" rel="nofollow noreferrer">JSF API</a> dependency:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;javax.faces&lt;/groupId&gt; &lt;artifactId&gt;javax.faces-api&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <p>This is causing trouble because this contains the blueprint class of <code>FacesServlet</code>. Removing it and relying on a <code>provided</code> Java EE (Web) API as shown above should solve it.</p> <p>Tomcat as being a barebones JSP/Servlet container already provides JSP, Servlet and EL (and since 8 also WebSocket) out the box. So you should mark at least <code>jsp-api</code>, <code>servlet-api</code>, and <code>el-api</code> as <code>provided</code>. Tomcat only doesn't provide JSF (and <a href="https://stackoverflow.com/tags/jstl/info">JSTL</a>) out the box. So you'd need to install it via the webapp.</p> <p>Full fledged Java EE servers such as WildFly, TomEE, GlassFish, Payara, WebSphere, etc already provide the entire Java EE API out the box, including JSF. So you do absolutely not need to install JSF via the webapp. It would only result in conflicts if the server already provides a different implementation and/or version out the box. The only dependency you need is the <code>javaee-web-api</code> exactly as shown here above.</p> <h2>Installing JSF on Tomcat</h2> <p>The proper way to install JSF in Tomcat is mentioned in <a href="https://stackoverflow.com/tags/jsf/info">our JSF wiki - Installing JSF</a>. There are 2 JSF implementations, <a href="https://stackoverflow.com/questions/4530746/difference-between-mojarra-and-myfaces">Mojarra and MyFaces</a>. You should choose to install one of them and thus <strong>not</strong> both.</p> <p>Installing Mojarra on Tomcat:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.glassfish&lt;/groupId&gt; &lt;artifactId&gt;javax.faces&lt;/artifactId&gt; &lt;version&gt;&lt;!-- Check https://javaserverfaces.github.io --&gt;&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>You can also check <a href="http://mvnrepository.com/artifact/org.glassfish/javax.faces" rel="nofollow noreferrer"><code>org.glassfish:javax.faces</code> repository</a> for current latest release version (which is currently <code>2.2.13</code>). See also <a href="https://github.com/javaserverfaces/mojarra/blob/master/README.md" rel="nofollow noreferrer">Mojarra's own installation instructions</a>.</p> <p>Installing MyFaces on Tomcat:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.myfaces.core&lt;/groupId&gt; &lt;artifactId&gt;myfaces-api&lt;/artifactId&gt; &lt;version&gt;&lt;!-- Check http://myfaces.apache.org --&gt;&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.myfaces.core&lt;/groupId&gt; &lt;artifactId&gt;myfaces-impl&lt;/artifactId&gt; &lt;version&gt;&lt;!-- Check http://myfaces.apache.org --&gt;&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>You can also check <a href="http://mvnrepository.com/artifact/org.apache.myfaces.core/myfaces-bundle" rel="nofollow noreferrer"><code>org.apache.myfaces.core:myfaces-bundle</code> repository</a> for current latest release version (which is currently <code>2.2.10</code>).</p> <p>Note that Tomcat 6 as being Servlet 2.5 container supports max JSF 2.1. Don't forget to install JSTL along, by the way. See also <a href="https://stackoverflow.com/tags/jsf/info">our JSF wiki - Installing JSF</a>.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/7295096/what-exactly-is-java-ee">What exactly is Java EE?</a></li> <li><a href="https://stackoverflow.com/questions/20268095/java-lang-noclassdeffounderror-javax-servlet-jsp-jstl-core-config/">java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config</a></li> <li><a href="https://stackoverflow.com/questions/18995951/how-to-install-and-use-cdi-on-tomcat/">How to install and use CDI on Tomcat?</a></li> <li><a href="https://stackoverflow.com/questions/3112946/jsf-returns-blank-unparsed-page-with-plain-raw-xhtml-xml-el-source-instead-of-re">JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload