From jira-events at lists.jboss.org Thu Jan 31 05:59:51 2013 Content-Type: multipart/mixed; boundary="===============7977724848444309620==" MIME-Version: 1.0 From: nicolas marchais (JIRA) To: jboss-jira at lists.jboss.org Subject: [jboss-jira] [JBoss JIRA] (AS7-6428) Using Session Scope CDI bean does not work in a HttpSessionListener Date: Thu, 31 Jan 2013 05:59:51 -0500 Message-ID: In-Reply-To: JIRA.12483908.1359629772000@jira02.app.mwc.hst.phx2.redhat.com --===============7977724848444309620== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ https://issues.jboss.org/browse/AS7-6428?page=3Dcom.atlassian.jira.p= lugin.system.issuetabpanels:all-tabpanel ] nicolas marchais updated AS7-6428: ---------------------------------- Issue Type: Bug (was: Feature Request) = > Using Session Scope CDI bean does not work in a HttpSessionListener > ------------------------------------------------------------------- > > Key: AS7-6428 > URL: https://issues.jboss.org/browse/AS7-6428 > Project: Application Server 7 > Issue Type: Bug > Components: CDI / Weld > Affects Versions: 7.1.1.Final > Environment: linux 64bits, win7 64 bits > Reporter: nicolas marchais > Assignee: Stuart Douglas > Fix For: No Release > > > JBoss AS 7.1.x has a bug with using session bean scope in a HttpSessionLi= stener. > When i inject a session scope bean in a HttpSessionListener and i try to = populate attribute in sessionCreated() method many HttpSession are created = by JBoss AS. Is it normal the a web server create many Http session for the= same request ? > Normally, this behaviour should work. See : http://docs.jboss.org/cdi/api= /1.1-PRD/javax/enterprise/context/SessionScoped.html > I did a light Web Project to explain the problem with 1 JSP, 1 SessionSco= pe bean and 1 HttpSessionListener. > Here is the code. > JSP page : > <%@ page language=3D"java" contentType=3D"text/html; charset=3DUTF-8" > pageEncoding=3D"UTF-8"%> > > > > > Insert title here > > > > > SessionScope bean : > @Named > @SessionScoped > public class UserState implements Serializable { > private int state; > public int getState() { > return state; > } > public void setState(int state) { > this.state =3D state; > } > } > HttpSessionListener : > @WebListener > public class SessionListener implements HttpSessionListener { > @Inject private UserState userState; > = > @Override > public void sessionCreated(HttpSessionEvent event) { > System.out.println("New HTTP Session created : " + event.getSession().g= etId()); > userState.setState(2); > } > @Override > public void sessionDestroyed(HttpSessionEvent event) {} > } > After execution, you can read in the console at least 2 http session crea= tion like this : > New HTTP Session created : zvlF6vGLP1AaXM-rzFU02wAJ.undefined > New HTTP Session created : TlrmmA8Eu4v32SHDT0QBBZza.undefined > The first session seams to be the one which is used by the client. There = is one more problem : The polutated attributes of the session scope bean ar= e ignored after HttpSessionListener execution. At the end all session scope= attributes are null. = -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs For more information on JIRA, see: http://www.atlassian.com/software/jira --===============7977724848444309620==--