【问题标题】:JSF 2 Annotations with Websphere 7 (JEE5, JAVA 1.6)带有 Websphere 7 的 JSF 2 注释(JEE5、JAVA 1.6)
【发布时间】:2010-05-17 15:50:17
【问题描述】:

我目前正在为 WAS 7 编写一个简单的 JSF 2 应用程序。当我通过 faces-config.xml 定义 bean 时,一切正常

<managed-bean>
     <managed-bean-name>personBean</managed-bean-name>
     <managed-bean-class>com.prototype.beans.PersonBean</managed-bean-class>
     <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

当我尝试改用下面的注释时,应用程序失败了。

package com.prototype.beans;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name="personBean")
@RequestScoped
public class PersonBean {
....
}

我已将 WAS 类加载器设置为 Parent Last,并在日志中验证 Mojarra 2.x 正在加载。

[5/17/10 10:46:59:399 CDT] 00000009 config        I   Initializing Mojarra 2.0.2 (FCS b10) for context '/JSFPrototype'

但是,当我尝试使用该应用程序(使用基于 XML 的配置)时,我看到以下内容

[5/17/10 10:48:08:491 CDT] 00000016 lifecycle     W   /pages/inputname.jsp(16,7) '#{personBean.personName}' Target Unreachable, identifier 'personBean' resolved to null
    org.apache.jasper.el.JspPropertyNotFoundException: /pages/inputname.jsp(16,7) '#{personBean.personName}' Target Unreachable, identifier 'personBean' resolved to null

有人知道怎么回事吗?

【问题讨论】:

    标签: jsf annotations websphere classloader jsf-2


    【解决方案1】:

    看起来我可能已经解决了我自己的问题(再次)。该问题看起来像是由面部配置上的不正确架构位置/配置引起的。这是我现在正在使用的,它似乎可以工作。

    <?xml version="1.0"?>
    <faces-config 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-facesconfig_2_0.xsd"
              version="2.0">
    </faces-config>
    

    【讨论】:

      【解决方案2】:

      里面的bean名字应该是你的bean类的名字 所以将 faces-config.xml 中的 beanName 更改为 &lt;managed-bean-name&gt;PersonBean&lt;/managed-bean-name&gt;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-10-15
        • 1970-01-01
        • 1970-01-01
        • 2014-08-05
        • 2014-08-22
        • 1970-01-01
        • 1970-01-01
        • 2015-01-02
        相关资源
        最近更新 更多