Cannot get a connection, pool error Timeout waiting for idle object

使用struts2 +hibernate+spring 作一個項目時,配置tomcat數據源刷新40屢次就會報
Cannot get a connection, pool error Timeout waiting for idle object錯誤。
感受就是spring管理的session沒有到達釋放
網上查資料說沒有配置OpenSessionInViewFilter 而致使的,而我已經配置了OpenSessionInViewFilter ,實在是沒找到頭緒
 
web.xml配置內容爲

        <listener>
                <listener- class>
                        com.going.framework.spring.web.context.ContextLoaderListener
                </listener- class>
        </listener>

        <filter>
                <filter-name>Struts2</filter-name>
                <filter- class>
                        org.apache.struts2.dispatcher.FilterDispatcher
                </filter- class>
        </filter>
        <filter-mapping>
                <filter-name>Struts2</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>


        <filter>
    <filter-name>hibernateFilter</filter-name>
     <filter- class>
     org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
     </filter- class>
</filter>
<filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
後來查閱大量資料後才發現 問題所在,應該先配置OpenSessionInViewFilter後再配置struts2的跳轉,這樣才能避免Cannot get a connection, pool error Timeout waiting for idle object這問題

  
    <listener>
                <listener- class>
                        com.going.framework.spring.web.context.ContextLoaderListener
                </listener- class>
        </listener>
        <filter>
    <filter-name>hibernateFilter</filter-name>
     <filter- class>
     org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
     </filter- class>
</filter>
<filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
        

        <filter>
                <filter-name>Struts2</filter-name>
                <filter- class>
                        org.apache.struts2.dispatcher.FilterDispatcher
                </filter- class>
        </filter>
        <filter-mapping>
                <filter-name>Struts2</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

    
相關文章
相關標籤/搜索