2014-09-01 79 views
0

我試圖從Hibernate 3.5升級項目到Hibernate 4.2,但現在我在Spring上下文初始化(我們正在使用Spring 3.2.2)。升級到休眠4:org.hibernate.TransactionException:無法提交JDBC連接

您可以在下面找到我們的配置。

任何想法是什麼可以是異常的原因? 將休眠版本還原爲3.5,異常消失。

... 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CLUSTERED_Scheduler' defined in class path resource [etc/scheduling/quartz-scheduling-context.xml]: Invocation of init method failed; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: commit failed; nested exception is org.hibernate.TransactionException: commit failed 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) 
    ... 
Caused by: org.springframework.orm.hibernate3.HibernateSystemException: commit failed; nested exception is org.hibernate.TransactionException: commit failed 
    at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:690) 
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:105) 
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517) 
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:755) 
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724) 
    at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:328) 
    at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:511) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1547) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485) 
    ... 36 more 
Caused by: org.hibernate.TransactionException: commit failed 
    at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:185) 
    at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:75) 
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:513) 
    ... 42 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:178) 
    ... 44 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) 
    ... 45 more 

在初始化Quartz調度程序bean期間發生異常。這是我們的配置:

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" 
    name="CLUSTERED_Scheduler" lazy-init="true"> 

    <property name="dataSource" ref="dataSource" /> 
    <property name="transactionManager" ref="transactionManager" /> 
    <property name="overwriteExistingJobs" value="false" /> 
    ... 
</bean> 

<bean id="entityManagerFactory" 
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" 
    p:dataSource-ref="dataSource" 
    p:persistenceXmlLocation="classpath:persistence.xml"> 
    <property name="jpaVendorAdapter"> 
     <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" 
      p:database="${jpa.database}" 
      p:showSql="${jpa.showSql}" 
      p:generateDdl="${jpa.generateDdl}" 
      p:databasePlatform="${jpa.databasePlatform}" /> 
    </property> 
</bean> 

<bean id="transactionManager" name="npp" 
    class="org.springframework.orm.jpa.JpaTransactionManager" 
    p:entityManagerFactory-ref="entityManagerFactory" 
    p:dataSource-ref="nppDataSource" 
/> 

這是persistence.xml中的內容:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
    version="1.0"> 
    <persistence-unit name="punit" transaction-type="RESOURCE_LOCAL"> 
     <provider>org.hibernate.ejb.HibernatePersistence</provider> 
     <class>...</class> 
     ... 
     <properties> 
      <property name="hibernate.ejb.interceptor" 
       value="my.Interceptor" /> 
     </properties> 
    </persistence-unit> 
</persistence> 

回答

1

它是春天的一個錯誤:SPR-10395 - 你應該把它更新到版本3.2.3+