You are lacking the <aop:scoped-proxy/> in the bean definition. See the following link:
http://static.springsource.org/spring/docs/3.0.7.RELEASE/spring-framework-reference/html/beans.html#beans-factory-scopes-other-injection HTH 2012/2/27 Samuel Robert <samuelrobert....@gmail.com>: > I am using Spring: > *<bean id="context" class="my.bean.SessionBean" scope="session"/>* > > In the action: > *@Autowired > private SessionBean context;* > > I can manipulate the context object in the action, fill it with a list of > profiles. > > > In the JSP, tags like the following fail (the first time only): > <s:select name="profile" id="profile" list="%{#session.context.profiles}"/> > > The application uses Spring Security and Tiles with the struts-tiles > plugin. > The jsp is included via Tiles: <result type="tiles">monitor</result> > > I am testing with Jetty. > > The stack trace: > Caused by: tag 'select', field 'list', name 'profile': The requested list > key '%{#session.context.profiles}' could not be resolved as a > collection/array/map/enu > meration/iterator type. Example: people or people.{name} - [unknown > location] > at > org.apache.struts2.components.Component.fieldError(Component.java:237) > at > org.apache.struts2.components.Component.findValue(Component.java:358) > at > org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80) > at > org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105) > at > org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856) > at org.apache.struts2.components.UIBean.end(UIBean.java:510) > at > org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42) > at > org.apache.jsp.jsp.monitor.inc_005fheader_005fmonitoring_jsp._jspx_meth_s_select_0(org.apache.jsp.jsp.monitor.inc_005fheader_005fmonitoring_jsp:367) > at > org.apache.jsp.jsp.monitor.inc_005fheader_005fmonitoring_jsp._jspx_meth_s_form_0(org.apache.jsp.jsp.monitor.inc_005fheader_005fmonitoring_jsp:313) > at > org.apache.jsp.jsp.monitor.inc_005fheader_005fmonitoring_jsp._jspx_meth_s_if_0(org.apache.jsp.jsp.monitor.inc_005fheader_005fmonitoring_jsp:262) > at > org.apache.jsp.jsp.monitor.inc_005fheader_005fmonitoring_jsp._jspService(org.apache.jsp.jsp.monitor.inc_005fheader_005fmonitoring_jsp:118) > at > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) > at > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389) > at > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486) > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) > at > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) > at > org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:366) > at > org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:99) > at > org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:60) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:57) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109) > at > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) > at > org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:167) > at > org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) > at > org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) > at > org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212) > at > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399) > at > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) > at > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) > at > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) > at > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450) > at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:192) > at > org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1013) > at > org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:698) > at > org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:80) > ... 132 more > > > On 27 February 2012 16:00, Gabriel Belingueres <belingue...@gmail.com>wrote: > >> Post the code in which you actually set the attribute in the session scope. >> >> 2012/2/27 Samuel Robert <samuelrobert....@gmail.com>: >> > Hi, >> > >> > I faced few days ago a problem with the session variable in the JSP. I >> > posted the problem here but did not get any solution: >> > >> http://stackoverflow.com/questions/9381991/session-variable-empty-in-the-jsp-on-first-access-in-a-struts2-spring-applicatio >> > >> > Perhaps some of you have an idea. >> > >> > Basically the session variable in the JSP is empty on the first call to >> my >> > action (when the session gets initialized). >> > That means that my JSP fails to retrieve any information from the session >> > in the Struts tags on the first display. >> > From the second call it is OK. >> > >> > I have checked that the session is correctly initialized in the JSP. The >> > problem comes only with the session variable in the struts tags. >> > >> > <% >> System.out.println(((my.bean.SessionBean)session.getAttribute("context")).getProfiles()); >> > %> => OK >> > >> > <s:property value="%{#session}"/> => KO (empty) >> > >> > ${session} => KO >> > >> > >> > I solved it by adding an additional redirectAction on the first access >> > (when I detect that it is a new session). >> > But I wonder why I get such a problem, which I never had before. >> > >> > Thanks, >> > Samuel >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org