【发布时间】:2011-09-08 08:09:35
【问题描述】:
对于在 NetBeans 6.9.1 中创建的新 JSF 2.0 应用程序,此错误消息会在生产服务器上启动时出现在日志文件中:
com.sun.faces.config.ConfigureListener contextInitialized:正在初始化 Mojarra 2.0.2 (FCS b10) 用于上下文''
com.sun.faces.spi.InjectionProviderFactory 创建实例:JSF1048: PostConstruct/PreDestroy 注释 展示。标记的 ManagedBeans 方法 有了这些注释就会说 已处理注释。
> com.sun.faces.config.ConfigureListener 安装ExpressionFactory:无法 实例化表达式工厂 'com.sun.el.ExpressionFactoryImpl'
上下文启动失败 com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@7616ad{/,/base/data/home/apps/scroogedemo/1.350894485313261302} com.sun.faces.config.ConfigurationException: 看来JSP版本的 容器早于 2.1 并且无法 定位 EL RI 表达式 工厂, com.sun.el.ExpressionFactoryImpl。如果 不使用 JSP 或 EL RI,请确保 上下文初始化参数, com.sun.faces.expressionFactory,是 正确设置。在 com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:638)
该应用使用 NetBeans 提供的 JSF 2.0 参考实现,其中似乎包含 EL RI(包 javax.faces.el)。
应用程序在开发服务器中运行良好。我在 web.xml 中使用这些配置条目:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
...
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableThreading</param-name>
<param-value>false</param-value>
</context-param>
我查看了页面 https://sites.google.com/a/wildstartech.com/adventures-in-java/Java-Platform-Enterprise-Edition/JavaServer-Faces/sun-javaserver-faces-reference-implementation/configuring-jsf-20-to-run-on-the-google-appengine/javaserverfaces-20-and-google-app-engine-compatibility-issues 以获取有关此错误的信息,但该问题并未在此处涵盖。
更新:上面提到的页面说项目中需要包含el-api和el-impl文件。它们不在 NetBeans 库列表中,因此它们没有在服务器部署过程中上载。我猜它们是由本地开发服务器提供的 - 但在生产 GAE 中缺失。原来是解决方案,见下文。
【问题讨论】:
-
您的 web.xml 是否声明符合 Servlet 2.5?该异常表明它被错误地设置为 2.4,或者 servletcontainer 本身实际上是一个 Servlet 2.4 容器。
-
@BalusC 查看我的更新,它是 2.5 版,这似乎是 GAE 级别(根据 code.google.com/appengine/docs/java/config/…)
标签: java google-app-engine netbeans jsf-2