2013-05-18 96 views
0

在我JSF2-Primefaces3 web應用中,我引用來自豆名爲「HomeBean」豆「CityBean」我使用ManagedBean註釋和沒有faces-config.xml中都得到ManagedBeanCreationException。請找到的代碼如下:注入託管bean時爲其他

HomeBean

@ManagedBean(name="HmBen") 
@SessionScoped 
public class HomeBean implements Serializable { 

    private static final long serialVersionUID = 1L; 
    private static Logger logger = Logger.getLogger(HomeBean.class); 

    private List<Offer> offersList; 

    public HomeBean() {  
    }  
} 

CityBean

@ManagedBean(name="CtyBen") 
@SessionScoped 
public class CityBean implements Serializable { 

    private static final long serialVersionUID = 1L; 

    @ManagedProperty(value="#{HmBen}") 
    private HomeBean homeBean;   

    public CityBean() {  
    } 

    /** 
    * Following setters are required as per the documentation for Dependancy 
    * Injection of beans to work 
    */ 
    public void setHomeBean(HomeBean homeBean) { 
      this.homeBean = homeBean; 
    }  
} 

注意:這只是一個由於施加#2字符限制的代碼段。

我得到以下異常:

Caused by: com.sun.faces.mgbean.ManagedBeanCreationException: Unable to set property homeBean for managed bean CtyBen 
    at com.sun.faces.mgbean.ManagedBeanBuilder$BakedBeanProperty.set(ManagedBeanBuilder.java:615) 
    at com.sun.faces.mgbean.ManagedBeanBuilder.buildBean(ManagedBeanBuilder.java:133) 
    ... 20 more 
Caused by: java.lang.IllegalStateException: Cannot create a session after the response has been committed 
    at org.apache.catalina.connector.Request.doGetSession(Request.java:2377) 

有沒有人有這方面有任何線索?

回答

0

響應已經提交讓我解釋它是什麼意思。在頁面上呈現它從上到下呈現。服務器以字節表示響應在渲染一些字節後,服務器獲取通知(如果頁面上有一些條件),現在您必須渲染字節,服務器無法獲取當時已經發送給用戶的字節服務器拋出IllegalState異常。給你的.xhtml頁面。請檢查一年前發佈的以下問題。 Jsf2.0 forwarding page error without parameter