首先,我想感謝您審查這個問題,並提供任何幫助 - 我非常感謝!SpringMVC 3.1中的應用程序,磨牀運行顯示「預期的會話屬性xxxxxx」錯誤
我在Openshift環境中開發了Spring MVC框架(3.1.1)中的應用程序。我已經測試過並且對其功能感到滿意。
當我加載性能測試的申請上磨牀,我收到以下消息時,他們中的很多:
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/].[MVCDispatcher]] (http-/127.8.157.1:8080-5) JBWEB000236: Servlet.service() for servlet MVCDispatcher threw exception: org.springframework.web.HttpSessionRequiredException: Expected session attribute 'session_account'
在我的申請,session_account是一個會話屬性(由@SessionAttribute定義({。 ..}))在3個類。它也被定義爲@ModelAttribute。
這三個類中的一個是LoginController.java,它通過由@ModelAttribute(「session_account」)註釋的方法初始化session_account。它還包含對用戶進行身份驗證的REST服務,並在身份驗證後將值設置爲session_account。我的功能測試(似乎)確認每個經過身份驗證的用戶都已定義了session_account。
現在來研磨機的性能測試。這裏有幾點意見:
大多數測試腳本產生了大量的上述錯誤信息;
當我限制磨牀運行一個用戶與一個(java)線程,沒有錯誤。只要我將環境放寬到多個用戶或多個(java)線程,就會發生此錯誤消息;
該錯誤消息似乎來自Spring層。我都很難把它映射到我的應用程序代碼(行)
在我的應用程序日誌,這個錯誤(線),稍後時間戳的行之後頻頻出現,例如:
2014/03/03 13:44:22,930 INFO [org.SandRiver.Controllers.JspController] (http-127.8.157.1/127.8.157.1:8080-32) home page 2014/03/03 13:44:22,822 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/].[MVCDispatcher]] (http-127.8.157.1/127.8.157.1:8080-54) JBWEB000236: Servlet.service() for servlet MVCDispatcher threw exception: org.springframework.web.HttpSessionRequiredException: Expected session attribute 'session_account'
我使用了「預期會話屬性」,並在Spring文檔中查閱了相關章節。不幸的是,我仍然在這裏尋求幫助。
我一直很迷茫,我什至不知道哪些文件/代碼片段與此問題有關。這裏是web.mxl,但很樂意提供更多,如果問。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true" version="3.0">
<display-name>LiquibilClient</display-name>
<servlet>
<servlet-name>MVCDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MVCDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/MVCDispatcher-servlet.xml,
/WEB-INF/applicationContext.xml,
/WEB-INF/application-security.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
附加問題:有人可以解釋什麼時候會引發此異常,這是什麼意思?謝謝 - 約翰 – user1693207