ファクトリーが見つかりませんでした:javax.faces.context.FacesContextFactory - 埋め込み Glassfish 3.0 を使用する
-
12-11-2019 - |
質問
埋め込み Glassfish 3.0 を使用して簡単な jsf-2.0 チュートリアルを実行しようとしていますが、このエラーが発生し続けます。このフォーラムやインターネットで解決策を探していますが、どこにも見つからないようです。ポムは次のとおりです。
<modelVersion>4.0.0</modelVersion>
<groupId>com.googlecode.sandcode</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<name>${project.artifactId}</name>
<version>1.0</version>
<repositories>
<repository>
<id>java.net.m2</id>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>java.net.glassfish.m2</id>
<url>http://download.java.net/maven/glassfish</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>glassfish-repository</id>
<name>Java.net Repository for Glassfish</name>
<url>http://download.java.net/maven/glassfish</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<!-- embedded glassfishV3 for testing -->
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.0</version>
<configuration>
<goalPrefix>glassfish</goalPrefix>
<app>target/helloworld-1.0.war</app>
<port>8080</port>
<contextRoot>test</contextRoot>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</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>
Web.xml:
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- explicitly setting the EL factory, otherwise is not working correctly under tomcat and jetty -->
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<!-- welcome file mapping -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
mvn パッケージを実行すると、war ファイルが生成され、glassfish が起動します。しかし、エラーを訴えます。プロジェクト フォルダーで、jsf Maven の依存関係が確認できます。jsf-api-2.1.jar。
ありがとう、サラ
解決
私自身の質問に答えます。:P
これを web.xml に追加して作業しました。
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener>
この問題について説明している Web ページは次のとおりです。 http://javawords.com/2009/06/05/using-jsf-12-with-facelets-on-google-app-engine-for-java/
埋め込まれた glassfish は起動時にサーブレットを初期化せず、最初のリクエストまで初期化が延期されるようです。
サラ
所属していません StackOverflow