Note that there are some explanatory texts on larger screens.

plurals
  1. POEclipse + Maven + JavaServer Faces -> ClassNotFoundException: StartupServletContextListener
    primarykey
    data
    text
    <p><strong>Summary</strong></p> <p>When I try to run a JSF 2.0 application from within Eclipse (on Tomcat 7.0) I get the following exception:</p> <pre><code>Problem: SEVERE: Error configuring application listener of class org.apache.myfaces.webapp.StartupServletContextListener java.lang.ClassNotFoundException: org.apache.myfaces.webapp.StartupServletContextListener </code></pre> <p><strong>Details</strong> </p> <p>I'm learning to develop JSF applications, using Eclipse. I started with a preconfigured Eclipse project: File->New->Dynamic Web Project->JavaServer Face v2.0 Project. Using this method Eclipse provides all dependencies. But I want to really learn how everything works. I want to remove the "magic", so I converted my project to a Maven project: Configure->Convert to Maven project.</p> <p>I then created my pom.xml (based on <a href="http://myfaces.apache.org/build-tools/archetypes/myfaces-archetype-helloworld20/index.html" rel="noreferrer">http://myfaces.apache.org/build-tools/archetypes/myfaces-archetype-helloworld20/index.html</a>), it contains the following:</p> <pre><code>&lt;build&gt; &lt;finalName&gt;jsf-facelets-tutorial&lt;/finalName&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;webXml&gt;WebContent/WEB-INF/web.xml&lt;/webXml&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;javax.el&lt;/groupId&gt; &lt;artifactId&gt;el-api&lt;/artifactId&gt; &lt;version&gt;1.0&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.0&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.myfaces.core&lt;/groupId&gt; &lt;artifactId&gt;myfaces-api&lt;/artifactId&gt; &lt;version&gt;2.0.5&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&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;2.0.5&lt;/version&gt; &lt;scope&gt;runtime&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; </code></pre> <p>But because I'm unfamiliar with JSF, and because this is an Eclipse "Dynamic Web Project", the project structure is new to me and I'm having trouble understanding which dependencies are coming from Maven and which are provided by the Eclipse "magic".</p> <p>In Eclipse, my project structure is as follows:</p> <pre><code>ProjectName JAX-WS Web Services &lt;-- CAN I REMOVE THIS??? Deployment Descriptor Java Resources src/main Libraries Apache Tomcat v7.0 el-api.jar jsp-api.jar [more...] JSF 2.0 (Apache MyFaces JSF Core-2.0 API 2.0.2) &lt;-- I REMOVED THIS!!! EAR Libraries JRE System Library Maven Dependencies el-api-1.0.jar myfaces-api-2.0.5.jar myfaces-impl-2.0.5.jar [more...] Web App Libraries </code></pre> <p><strong>Problem</strong> My (very basic) application (login page &amp; welcome page) no longer runs. When I do the following:</p> <pre><code>(1) Right click on WebContent/login.xhtml (2) Run as -&gt; Run on Server (3) Apache Tomcat v7.0 - JDK6 at localhost </code></pre> <p>I get the exception:</p> <pre><code>Problem: SEVERE: Error configuring application listener of class org.apache.myfaces.webapp.StartupServletContextListener java.lang.ClassNotFoundException: org.apache.myfaces.webapp.StartupServletContextListener </code></pre> <p>I have the feeling that this is very easy to fix, but I'm too unfamiliar with these frameworks to work it out.</p> <p>If there are any additional details I should provide (web.xml, faces-config-xml, login.xhtml), let me know and I'll add them.</p> <p>Thanks!</p> <p><strong>EDIT</strong></p> <p>WEB-INF/lib is always empty. From my understanding, it's necessary to copy all dependencies into this folder, that will be required at runtime, and that are not provided by the Web Container. The reasons mine is empty are: (1) I don't know what I need in there (2) I don't know how to automate the process of putting .jar files in there</p>
    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.
 

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