【问题标题】:CDI managed bean in Mojarra 2.3 throws PropertyNotFoundException, Target Unreachable, identifier 'localeBean' resolved to nullMojarra 2.3 中的 CDI 托管 bean 抛出 PropertyNotFoundException,目标无法访问,标识符“localeBean”解析为 null
【发布时间】:2018-04-17 05:16:22
【问题描述】:

我在 JSF 2.3 和 CDI 应用程序中发现 bean 时遇到问题。我正在使用 Glassfish 5.0、Java 8 (1.8.0_151)。我的文件:

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
              version="2.3">


</faces-config>

LocaleBean:

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Named
@SessionScoped
public class LocaleBean implements Serializable {

}

向此 bean 提交表单后 Glassfish 日志中的消息:

javax.el.PropertyNotFoundException: /home.xhtml @15,81 value="#{localeBean.language}": 目标不可达,标识符“localeBean”解析为空

仅当我使用下面列出的导入而不是 javax.enterprise.context 包中的 @Named 和 @SessionScoped 时,表单提交才有效。

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

但两者在 JSF 2.3 中都已弃用。

有什么想法吗?谢谢!

【问题讨论】:

标签: jsf cdi mojarra propertynotfoundexception jsf-2.3


【解决方案1】:

我在 GitHub 上的这个主题中找到了解决方案及其描述:

https://github.com/javaserverfaces/mojarra/issues/4264

【讨论】:

    猜你喜欢
    • 2015-09-14
    • 2019-05-10
    • 2012-10-17
    • 2013-07-20
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    • 2016-03-09
    • 2022-12-12
    相关资源
    最近更新 更多