0

在 log 中,我收到以下异常。可能的原因是什么?应用程序有 Spring 3.1、hibernate 3.6.9 和最新的 mysql。

        11:54:25,158 ERROR LoginController:152 - org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin failed: 
            at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:427)
            at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
            at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
            at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
            at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
            .....
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
            at java.lang.Thread.run(Thread.java:722)
        Caused by: javax.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin failed: 
            at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1215)
            at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148)
            at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1225)
            at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:63)
            at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70)
            at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:377)
            ... 50 more
        Caused by: org.hibernate.TransactionException: JDBC begin failed: 
            at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:92)
            at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
            at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:60)
            ... 52 more
        Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
4

2 回答 2

0

看起来您丢失了 MySQL 连接。这可能是网络问题或 MySQL 端的问题。

于 2013-02-13T09:07:11.247 回答
0

在persistance.xml中实现连接池(C3PO)后解决

于 2013-02-18T08:00:18.323 回答