Code Bye

Could not open Hibernate Session for transaction; nested exception is org.hibern

网站爆这个错误,,
本地测试不会有这个错误
http://dwz.minnanseo.com:8080/
刷新下就 可以正常访问。。
不懂为什么 。。
数据库一些设置不太清楚
HTTP Status 500 –

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin failed: 
org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:599)
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377)
org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy8.login(Unknown Source)
com.sec.action.UserAction.login(UserAction.java:71)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause

org.hibernate.TransactionException: JDBC begin failed: 
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:96)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)
org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:558)


20分
http://blog.csdn.net/cpp_lzth/article/details/7531221这个网站上说什么数据库连接超时 以及解决办法

50分
在你的spring配置数据源里面,加上如下几个配置:

 <property name=”testOnBorrow” value=”true”></property>
  <property name=”testOnReturn” value=”true”></property>
  <property name=”testWhileIdle” value=”true”></property>
   <property name=”validationQuery” value=”SELECT 1″></property>
   <property name=”timeBetweenEvictionRunsMillis” value=”检查无效连接的时间间隔”></property>
   <property name=”minEvictableIdleTimeMillis” value=”连接闲置的时间”></property>

然后再试试


10分
我遇到过,你贴一下spring里边的数据库配置代码
2 楼的 。   加上你 的 配置项目就报错了 。。
贴下我 的 配置。。。

<!– 配置SessionFactory –>
<bean id=”sessionFactory” class=”org.springframework.orm.hibernate3.LocalSessionFactoryBean”>
<!– 指定hibernate的配置文件位置 –>
<property name=”configLocation” value=”classpath:hibernate.cfg.xml”></property>
<!– 配置c3p0数据库连接池 –>
<property name=”dataSource”>
<bean class=”com.mchange.v2.c3p0.ComboPooledDataSource”>
<!– 数据连接信息 –>
<property name=”jdbcUrl” value=”${jdbcUrl}”></property>
<property name=”driverClass” value=”${driverClass}”></property>
<property name=”user” value=”${user}”></property>
<property name=”password” value=”${password}”></property>
<!– 其他配置 –>
<!–初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 –>
<property name=”initialPoolSize” value=”3″></property>
<!–连接池中保留的最小连接数。Default: 3 –>
<property name=”minPoolSize” value=”3″></property>
<!–连接池中保留的最大连接数。Default: 15 –>
<property name=”maxPoolSize” value=”5″></property>
<!–当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 –>
<property name=”acquireIncrement” value=”3″></property>
<!– 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 –>
<property name=”maxStatements” value=”8″></property>
<!–maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 –>
<property name=”maxStatementsPerConnection” value=”5″></property>
<!–最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 –>
<property name=”maxIdleTime” value=”1800″></property>
<property name=”testOnBorrow” value=”true”></property>
 
</bean>
</property>
</bean>

引用 5 楼 shijing266 的回复:
Quote: 引用 4 楼 u010569017 的回复:

2 楼的 。   加上你 的 配置项目就报错了 。。
贴下我 的 配置。。。

<!– 配置SessionFactory –>
<bean id=”sessionFactory” class=”org.springframework.orm.hibernate3.LocalSessionFactoryBean”>
<!– 指定hibernate的配置文件位置 –>
<property name=”configLocation” value=”classpath:hibernate.cfg.xml”></property>
<!– 配置c3p0数据库连接池 –>
<property name=”dataSource”>
<bean class=”com.mchange.v2.c3p0.ComboPooledDataSource”>
<!– 数据连接信息 –>
<property name=”jdbcUrl” value=”${jdbcUrl}”></property>
<property name=”driverClass” value=”${driverClass}”></property>
<property name=”user” value=”${user}”></property>
<property name=”password” value=”${password}”></property>
<!– 其他配置 –>
<!–初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 –>
<property name=”initialPoolSize” value=”3″></property>
<!–连接池中保留的最小连接数。Default: 3 –>
<property name=”minPoolSize” value=”3″></property>
<!–连接池中保留的最大连接数。Default: 15 –>
<property name=”maxPoolSize” value=”5″></property>
<!–当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 –>
<property name=”acquireIncrement” value=”3″></property>
<!– 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 –>
<property name=”maxStatements” value=”8″></property>
<!–maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 –>
<property name=”maxStatementsPerConnection” value=”5″></property>
<!–最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 –>
<property name=”maxIdleTime” value=”1800″></property>
<property name=”testOnBorrow” value=”true”></property>
 
</bean>
</property>
</bean>

报什么错

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name “”com.mchange.v2.c3p0.ComboPooledDataSource#1aba2ee”” defined in file [D:\data\webdata\dwzssh\WEB-INF\classes\applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property “”testOnReturn”” of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: No property “”testOnReturn”” found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:219)
… 44 more
Caused by: org.springframework.beans.InvalidPropertyException: Invalid property “”testOnReturn”” of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: No property “”testOnReturn”” found
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:382)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1249)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
… 48 more

这些  个 没有 定义。。。。 

<property name=”url” value=”jdbc:mysql://localhost/数据库实例名  
称?&useUnicode=true&characterEncoding=utf-8&autoReconnect=true”/>  
 我给 jdbc  加了 链接了      autoReconnect=true
  还是一样 。。 


10分
应该是数据库连接没有close掉,导致现在连接失败

10分
貌似数据库连接的配置文件有问题或者是jar包问题。
已经决解了 谢谢 大家了。。   

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Could not open Hibernate Session for transaction; nested exception is org.hibern