JEEBBS论坛 » 二次开发技术交流 » 网站第一次打不开,Could not open Hibernate Session for transaction.nested exception is org.hib。刷新一下就打开i了

主题 : 网站第一次打不开,Could not open Hibernate Session for transaction.nested exception is org.hib。刷新一下就打开i了 |
级别: 贡士
![]() |
21# 发表于:2014-01-27 10:53:46 IP:112.132.*.*
|
||||
---|---|---|---|---|---|
级别: 举人
![]() |
23# 发表于:2015-09-10 09:48:10 IP:120.7.*.*
application-context.xml 文件增加两行
<!-- 新增 --> <property name="idleConnectionTestPeriod" value="120"/> <!-- 新增 --> hibernate.autoReconnect=true 位置如下: cat application-context.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd" default-lazy-init="true"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>/WEB-INF/config/jdbc.properties</value> </list> </property> </bean> <bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>/WEB-INF/config/jdbc.properties</value> <value>/WEB-INF/config/jeecms/jeecms.properties</value> <value>/WEB-INF/config/plug/**/*.properties</value> </list> </property> <qualifier value="main"/> </bean> <bean id="propertyUtils" class="com.jeecms.common.util.PropertyUtils"> <property name="properties" ref="properties"/> </bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClassName}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="autoCommitOnClose" value="true"/> <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> <property name="initialPoolSize" value="${cpool.minPoolSize}"/> <property name="minPoolSize" value="${cpool.minPoolSize}"/> <property name="maxPoolSize" value="${cpool.maxPoolSize}"/> <property name="maxIdleTime" value="${cpool.maxIdleTime}"/> <property name="acquireIncrement" value="${cpool.acquireIncrement}"/> <property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/> <!-- 新增 --> <property name="idleConnectionTestPeriod" value="120"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingLocations" value="#{propertyUtils.getList('hibernate.hbm')}"/> <property name="hibernateProperties"> <value> hibernate.dialect=${hibernate.dialect} hibernate.show_sql=false hibernate.format_sql=false hibernate.query.substitutions=true 1, false 0 hibernate.jdbc.batch_size=20 hibernate.cache.use_query_cache=true <!-- 新增 --> hibernate.autoReconnect=true </value> </property> <property name="entityInterceptor"> <ref local="treeInterceptor"/> </property> <property name="cacheProvider"> <ref local="cacheProvider"/> </property> <property name="lobHandler"> <ref bean="lobHandler" /> </property> </bean> <bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/> <bean id="cacheProvider" class="com.jeecms.common.hibernate3.SpringEhCacheProvider"> <property name="configLocation"> <value>/WEB-INF/config/ehcache-hibernate.xml</value> </property> <property name="diskStoreLocation"> <value>/WEB-INF/cache/hibernate</value> </property> </bean> <bean id="treeInterceptor" class="com.jeecms.common.hibernate3.TreeIntercptor"/> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <context:annotation-config/> <tx:annotation-driven transaction-manager="transactionManager" /> </beans> |
||
---|---|---|---|