当前位置: 首页 > 知识库问答 >
问题:

升级到Hibernate 4后出现错误“提交失败”

锺离旻
2023-03-14

我正在尝试将项目从3.6.10版升级到4.3.6版,在应用程序启动时出现“提交失败”错误。而不是使用:

SessionFactoryUtils.getSession(sessionFactory, allowCreate);

,为了获得会话,现在我正在使用:

sessionFactory.getCurrentSession();

事务由TransactionManager和Spring的NameMatchTransactionAttribute资源处理。

这是我得到的堆栈跟踪:

    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.MethodInvokingFactoryBean#0' defined in class path resource [frontmvcSpringContext.xml]: Invocation of init method failed; nested exception is org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: commit failed
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:681)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: commit failed
    at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:561)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:478)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:272)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at com.sun.proxy.$Proxy34.setExecutionsInProgressInError(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269)
    at org.springframework.beans.factory.config.MethodInvokingFactoryBean.doInvoke(MethodInvokingFactoryBean.java:166)
    at org.springframework.beans.factory.config.MethodInvokingFactoryBean.afterPropertiesSet(MethodInvokingFactoryBean.java:156)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
    ... 21 more
Caused by: org.hibernate.TransactionException: commit failed
    at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:187)
    at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:557)
    ... 37 more
Caused by: org.hibernate.TransactionException: unable to commit against JDBC connection
    at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:116)
    at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:180)
    ... 38 more
Caused by: java.sql.SQLException: Connection is closed.
    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:185)
    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.commit(PoolingDataSource.java:210)
    at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:112)
    ... 39 more

这是我的会话工厂bean配置:

<!-- Hibernate SessionFactory -->
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource"  ref="DataSource"/>
    <property name="hibernateProperties"  ref="HibernateProperties"/>
</bean> 

共有2个答案

百里丁雨
2023-03-14

这是Spring中的一个bug:SPR-10395-您应该将其更新到3.2.3版本

张和豫
2023-03-14

我设法删除了java.sql.SQLException:连接已关闭。

<代码>

在我的会话工厂hibernate属性中,在我的Spring配置xml中。

 类似资料:
  • 问题内容: 我有一个用于签署XML文档的Java应用程序。将Java升级到最新版本(Java7u25)后,它将停止工作。我收到以下错误: 恢复为java7u21解决了该问题。XML Dig Sig API中是否有任何导致此错误的更改? 问题答案: 这里同样的问题。由于不断发展,似乎是JVM内部的错误。 我已经将其归结为 在Java 7u21及之前的版本中: 在Java 7u25中: 指的是XML

  • 在将我的计算机升级到乌龟SVN版本从1.6升级到1.8.3(SVN 1.8.4)后,我得到了可怕的403禁止错误。 null 在防火墙或身份验证方面,1.8有什么不同吗?Apache服务器使用html并使用网络密码进行身份验证。下一步有哪些举措?

  • 我正在Mac OS X上运行。我最近将node和npm更新到了最新版本,按照以下已接受的回答步骤将node.js升级到Mac OS上的最新版本。node:和npm:现在当我运行我的Gulp文件时,我得到了这个错误: 有人知道这是什么问题吗?

  • 在我升级到Typescript 2.9.1(从2.8)之后,我得到了编译错误 当我使用typecript 2.7和2.8时,这从未发生过。 环境: MacOS 10.13.5 节点。JSV9。11.1 NPM:6.1.0 Typescript 2.9.1(在我的项目的文件夹中,没有全局Typescript)

  • 在macOS上的设置中,我使用了几个JDK,通过工具在它们之间切换,类似于本SO答案中描述的方法 升级到macOS Big Surv11.0.1后,我的JAVA_HOME设置停止工作,始终报告相同的java版本:

  • 运行Firebase upgrade命令后,我尝试在模拟器中运行我的应用程序,出现了以下错误消息: 在调试模式下在 sdk gphone64 x86 64 上启动 lib\main.dart...运行 Gradle 任务 'assembleDebug'... /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.