Hi Experts,
I have a JSF session-scoped bean called UserBean which looks as follow:
public class UserBean {
private String user;
public void setUser(String user) {
this.user = user;
}
public String getUser() {
return user;
}
}
I also have two request-scoped page beans that are identical but contained in seperate WAR applications:
public class PageBean {
public void setUser(String user) {
getUserBean().setUser(user);
}
public String getUser() {
return getUserBean().getUser();
}
private UserBean getUserBean() {
ELContext elContext = FacesContext.getCurrentInstance().getELContext();
ELResolver elResolver = FacesContext.getCurrentInstance().getApplication().getELResolver();
return (UserBean)elResolver.getValue(elContext, null, "userbean");
}
I package all of these beans together in an EAR file, with the UserBean contained in a JAR in the lib folder, and the two WARs placed under the root, as such:
EAR
|___ PageBean1.war
|___ PageBean2.war
|___ lib
|___ UserBean.jar
Now, if I load the PageBean1 application and call setUser followed by getUser in another browser window (on PageBean1) it works fine and vice versa for PageBean2. If I, however, call setUser on PageBean1 but getUser on PageBean2, or vice versa, the method returns null, indicating that they have two different instances of UserBean, even though it is session-scoped. I need them to refer to the same instance.
Any ideas?
Thank you,
Ristretto