在我的 JSF2-Primefaces3 Web 应用程序中,我从 bean“CityBean”中引用名为“HomeBean”的 bean,我使用的是 ManagedBean 注释,根本没有 faces-config.xml。请找到如下代码:
家豆
@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() {
}
}
城市豆
@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;
}
}
注意:由于 Stackoverflow 施加的字符限制,这只是代码的一部分。
我收到以下异常:
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)
有人对此有任何线索吗?