(1) Spring throws an exception point: org.springframework.orm.jpa.EntityManagerFactoryUtils
Public StaticDataAccessException Convertjpaaccessexceptionifpossible (RuntimeException ex) {//following the JPA specification, a persistence provider can also//throw these, exceptions, besides persistenceexception. if(exinstanceofillegalstateexception) { return Newinvaliddataaccessapiusageexception (Ex.getmessage (), ex); } if(exinstanceofillegalargumentexception) { return Newinvaliddataaccessapiusageexception (Ex.getmessage (), ex); } //Check for well-known persistenceexception subclasses. if(exinstanceofentitynotfoundexception) { return Newjpaobjectretrievalfailureexception ((entitynotfoundexception) ex); } if(exinstanceofnoresultexception) { return NewEmptyresultdataaccessexception (Ex.getmessage (), 1, ex); } if(exinstanceofnonuniqueresultexception) { return NewIncorrectresultsizedataaccessexception (Ex.getmessage (), 1, ex); } if(exinstanceofquerytimeoutexception) { return Neworg.springframework.dao.QueryTimeoutException (Ex.getmessage (), ex); } if(exinstanceoflocktimeoutexception) { return Newcannotacquirelockexception (Ex.getmessage (), ex); } if(exinstanceofpessimisticlockexception) { return Newpessimisticlockingfailureexception (Ex.getmessage (), ex); } if(exinstanceofoptimisticlockexception) { return Newjpaoptimisticlockingfailureexception ((optimisticlockexception) ex); } if(exinstanceofentityexistsexception) { return Newdataintegrityviolationexception (Ex.getmessage (), ex); } //the point at which the exception is thrown if(exinstanceoftransactionrequiredexception) { return Newinvaliddataaccessapiusageexception (Ex.getmessage (), ex); } //If We have another kind of persistenceexception, throw it. if(exinstanceofpersistenceexception) { return NewJpasystemexception (ex); } //If We get here, we have a exception that resulted from the user code,//rather than the persistence provider, so we return NULL to indicate//That's translation should not occur. return NULL; }
View Code
(2) Exception information
Error org.springframework.aop.interceptor.simpleasyncuncaughtexceptionhandler-unexpected error occurred invoking Async method ' public void (here omit specific industry Event listener Class) Listener.onapplicationevent (Completeevent) '. Org.springframework.dao.InvalidDataAccessApiUsageException:no transaction is in progress; nested exception is Javax.persistence.TransactionRequiredException:no transaction is in progress at Org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible ( Entitymanagerfactoryutils.java:413) ~[spring-orm-4.3.9.release.jar:4.3.9. RELEASE] at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible ( Hibernatejpadialect.java:246) ~[spring-orm-4.3.9.release.jar:4.3.9. RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible ( Abstractentitymanagerfactorybean.java:488) ~[spring-orm-4.3.9.release.jar:4.3.9. RELEASE] at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible ( Chainedpersistenceexceptiontranslator.java:(~[spring-tx-4.3.9.release.jar:4.3.9). RELEASE] at Org.springframework.dao.support.DataAccessUtils.translateIfNecessary (Dataaccessutils.java:213) ~[spring-tx-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke ( Persistenceexceptiontranslationinterceptor.java:147) ~[spring-tx-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (Reflectivemethodinvocation.java :179) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at org.springframework.data.jpa.repository.support.crudmethodmetadatapostprocessor$ Crudmethodmetadatapopulatingmethodintercceptor.invoke (Crudmethodmetadatapostprocessor.java:122) ~[spring-data-jpa-1.8.0. RELEASE.jar:na] at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed ( Reflectivemethodinvocation.java:179) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke ( Exposeinvocationinterceptor.java:(spring-aop-4.3.9.release.jar:4.3.9) [. RELEASE] at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (Reflectivemethodinvocation.java :179) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.framework.JdkDynamicAopProxy.invoke (Jdkdynamicaopproxy.java:213) ~[spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at Com.sun.proxy. $Proxy 55.saveAndFlush (Unknown Source)~[Na:na]//omitting business class informationAt Org.springframework.cglib.proxy.MethodProxy.invoke (methodproxy.java:204) [spring-core-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.framework.cglibaopproxy$cglibmethodinvocation.invokejoinpoint ( Cglibaopproxy.java:738) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (Reflectivemethodinvocation.java :157) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at org.springframework.transaction.interceptor.transactioninterceptor$1.proceedWithInvocation (transactioninterceptor.java:99) ~[spring-tx-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction ( Transactionaspectsupport.java:282) [spring-tx-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.transaction.interceptor.TransactionInterceptor.invoke ( Transactioninterceptor.java:(+) [spring-tx-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (Reflectivemethodinvocation.java :179) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke ( Exposeinvocationinterceptor.java:(spring-aop-4.3.9.release.jar:4.3.9) [. RELEASE] at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (Reflectivemethodinvocation.java :179) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.framework.cglibaopproxy$dynamicadvisedinterceptor.intercept ( Cglibaopproxy.java:673) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] atl$ $EnhancerBySpringCGLIB $ $a 432af48.complete (<generated>) ~--At Org.springframework.transaction.interceptor.TransactionInterceptor.invoke (Transactioninterceptor.java: (+) [spring-tx-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (Reflectivemethodinvocation.java :179) [spring-aop-4.3.9.release.jar:4.3.9. RELEASE] at Org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke ( Persistenceexceptiontranslationinterceptor.java:136) ~[spring-tx-4.3.9.release.jar:4.3.9. RELEASE] ...Common frames omitted
View Code
Spring Source Learning Spring configuration Transaction mode is required, but business layer throws transactionrequiredexception exception problem