2010-05-17 62 views
1

我目前正在写一个简单的JSF 2应用程序为WAS 7.当我通过faces-config.xml中定义bean,一切都很正常JSF 2个注解与WebSphere 7(JEE5,JAVA 1.6)

<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类加载器父最后,并在钻嘴鱼科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 

任何人都知道什么回事?

回答

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作为 <managed-bean-name>PersonBean</managed-bean-name>

+0

不,你错了名字。 – BalusC 2011-08-04 17:07:07