概要のEclipse + Mavenの+のJavaServer Facesを - >にClassNotFoundException:StartupServletContextListener
私は(Tomcatの7.0で)Eclipse内からJSF 2.0アプリケーションを実行しようとすると、私は次の例外を取得:
Problem: SEVERE: Error configuring application listener of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.ClassNotFoundException: org.apache.myfaces.webapp.StartupServletContextListener
を
詳細
Eclipseを使用してJSFアプリケーションを開発する方法を学んでいます。 私は、事前設定されたEclipseプロジェクト、File-> New-> Dynamic Web Project-> JavaServer Face v2.0 Projectから始めました。 このメソッドを使用すると、Eclipseはすべての依存関係を提供します。しかし、私は本当にすべての仕組みが学びたいと思っています。私は "マジック"を削除したいので、私はプロジェクトをMavenプロジェクトに変換しました:Configure-> Convert to Mavenプロジェクト。
私はその後、(http://myfaces.apache.org/build-tools/archetypes/myfaces-archetype-helloworld20/index.htmlに基づいて)私のpom.xmlを作成し、それには、次のものが含まれています
<build>
<finalName>jsf-facelets-tutorial</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>WebContent/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>2.0.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>2.0.5</version>
<scope>runtime</scope>
</dependency>
</dependencies>
しかし、私はJSFに不慣れだから、これはEclipseの「動的Webプロジェクト」であるので、プロジェクトの構造は私には新しく、依存関係がMavenから来ていることと、Eclipseの "魔法"によって提供されていることを理解するのが難しいです。次のようにEclipseで
は、私のプロジェクト構造は次のとおりです。
ProjectName
JAX-WS Web Services <-- 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) <-- 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
問題 私(非常に基本的な)アプリケーション(ログインページ&ウェルカムページ)もはや実行されます。 私は次の操作を実行した場合:
(1) Right click on WebContent/login.xhtml
(2) Run as -> Run on Server
(3) Apache Tomcat v7.0 - JDK6 at localhost
を、私は例外を取得:
Problem: SEVERE: Error configuring application listener of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.ClassNotFoundException: org.apache.myfaces.webapp.StartupServletContextListener
私は、これは修正することは非常に容易であるという感覚を持っているが、私はそれを動作するようにこれらのフレームワークで、あまりにも慣れていないんですでる。
追加情報(web.xml、faces-config-xml、login.xhtml)を提供する必要がある場合は、お知らせください。追加します。
ありがとうございます!
EDIT
WEB-INF/libには常に空です。私の理解では、すべての依存関係をこのフォルダにコピーする必要があります。これは実行時に必要となるもので、Webコンテナでは提供されません。私がそこに必要なものがわからない(2)そこに.jarファイルを入れるプロセスを自動化する方法がわからない
デプロイメント・アセンブリでは、**(1)** SOURCE =/src/main、DEPLOY PATH = WEB-INF/classes **(2)** SOURCE =/WebContent、DEPLOY PATH =/ –
追加ビルドをクリックし、Java BuildPath Entriesを選択します。すべて選択して追加します。これはWEB-INF/libに追加するすべての依存関係を選択する場所です – vinodn
"Maven Dependencies"を "Deployment Assembly"に追加するとすべて動作します再び。ありがとう! –