title: org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Resource.java
    
    @RequestMapping(value = "/updateDetails", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
      @PreAuthorize("hasRole('" + ROLE_BPM_EAUTH_WF_CLIENT + "')")
      public ResponseEntity&lt;UpdateStatus&gt; updateDetails(@RequestBody updateRequest updateRequest) throws ServiceException {
          UpdateStatus response = null;
          try{
               response = controlService.updateDetails(updateRequest);
          }catch (ControlServiceException controlServiceException) {
              if(ErrorCodes.ERROR_CODE.FAILED_TO_UPDATE_DETAILS.getCode().equals(controlServiceException.getErrorCode())
                      || ErrorCodes.ERROR_CODE.FAILED_TO_UPDATE_DETAILS_STALE_DATA_ISSUE.getCode().equals(controlServiceException.getErrorCode())) {
                      final int maxRetryCount = controlService.getMaxRetryCountFromConfig(); 
                      response = retryUpdateDetails(updateRequest, 1, maxRetryCount);
              } else{
                  throw controlServiceException;
                  }
              }
          return new ResponseEntity&lt;&gt;(response, HttpStatus.OK);
      }
   
  Service.java
   
  @Override
  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = { ServiceException.class })
  public UpdateStatus updateDetails(UpdateRequest updateRequest) throws ServiceException {
   Object object = updateRequest.getObject();
   updateDetailActions(updateRequest);
   return InformationTransformer.transformStatus(object, true);
  
  }
   
  private void updateDetailActions(updateRequest updateRequest) throws ServiceException {
   DefaultDetails defaultDetails = null;
   if (updateRequest.getEventType().equals(EventTypeEnum.A.getValue())) {
    updateStatusToA(updateRequest);
   }
   Object object = updateRequest.getObject();
   
   ObjectDetail localObjectDetail = objectDetailRepo.getObjectDetailsByCriteria(object);
   ObjectDetail objectDetail = objectCreateHelper.createOrReplaceObjectDetails(updateRequest, localObjectDetail, object);
   EventTypeEnum eventType = EventTypeEnum.getByName(updateRequest.getEventType());
   Boolean isUpdateBSRequired = objectCreateHelper.isRESTCallRequired(updateRequest, localObjectDetail);
   
   if(isUpdateBSRequired){
    defaultDetails = objectCreateHelper.setBSDetails(objectDetail,object);
   }
   performEventRelatedUpdates(updateRequest, objectDetail, eventType);
       
   try {
      populateObjectCriticalityForEvents(updateRequest ,object, objectDetail);
   } catch (ControlServiceException e) {
    throw new ControlServiceException(ErrorCodes.ERROR_CODE.FAILED_TO_POPULATE_CRITICALITY, e);
   } finally {
    objectDetail = saveObjectDetails(objectDetail, object);
    if(isUpdateBSRequired){
     objectCreateHelper.updateBS(object, defaultDetails);
     if(objectCreateHelper.isPUEnabled(object)){
      performPU(object, objectDetail);
     }
    }
   }
  }
   
  @Override
  public ObjectDetail saveDetails(ObjectDetail objectDetail, Object object) throws ControlServiceException {
   try {
    return objectDetailRepo.saveDetail(objectDetail);
   } catch (ObjectOptimisticLockingFailureException exception){
      throw new ControlServiceException(ErrorCodes.ERROR_CODE.FAILED_TO_UPDATE_DETAILS_STALE_DATA_ISSUE, exception);
   }  catch (Exception ex) {
    throw new ControlServiceException(ErrorCodes.ERROR_CODE.FAILED_TO_UPDATE_DETAILS, ex);
   }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>exception logs :
  
  
   Exception occurred while saving Object as org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress
   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)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:227)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:43)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
    at com.sun.proxy.$Proxy282.saveekDetail(Unknown Source)
    at com.ek.acp.service.ekcontrol.impl.ekControlServiceImpl.saveekDetails(ekControlServiceImpl.java:1184)
    at com.ek.acp.service.ekcontrol.impl.ekControlServiceImpl.updateekDetailActions(ekControlServiceImpl.java:331)
    at com.ek.acp.service.ekcontrol.impl.ekControlServiceImpl.updateekDetails(ekControlServiceImpl.java:276)
    at sun.reflect.GeneratedMethodAccessor764.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
    at com.ek.egsframework.persistence.serviceinterceptors.EGSTransactionInterceptor.executeService(EGSTransactionInterceptor.java:125)
    at com.ek.egsframework.persistence.serviceinterceptors.EGSTransactionInterceptor.transactionWithoutEGSServiceMethod(EGSTransactionInterceptor.java:67)
    at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
    at com.ek.egsframework.persistence.serviceinterceptors.ModuleManagerInterceptor.checkEGServiceAnnotation(ModuleManagerInterceptor.java:65)
    at sun.reflect.GeneratedMethodAccessor165.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:58)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
    at com.sun.proxy.$Proxy348.updateekDetails(Unknown Source)
    at com.ek.acp.controller.events.ekEventResource.updateekDetails(ekEventResource.java:108)
    at com.ek.acp.controller.events.ekEventResource$$FastClassBySpringCGLIB$$c1e0a006.invoke(&lt;generated&gt;)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:718)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:68)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:654)
    at com.ek.acp.controller.events.ekEventResource$$EnhancerBySpringCGLIB$$d7109e94.updateekDetails(&lt;generated&gt;)
    at sun.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at com.ek.web.filter.RequestMDCLogger.doFilter(RequestMDCLogger.java:39)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:104)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:242)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:118)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at com.ek.authentication.jwt.JwtAuthenticationFilter.successfulAuthentication(JwtAuthenticationFilter.java:188)
    at com.ek.authentication.jwt.JwtAuthenticationFilter.doAuthenticate(JwtAuthenticationFilter.java:104)
    at com.ek.authentication.jwt.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:72)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at com.ek.security.ping.EGSPingAuthenticationFilter.doFilterInternal(EGSPingAuthenticationFilter.java:114)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at com.ek.web.filter.PingRequestFilter.doFilterInternal(PingRequestFilter.java:107)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:111)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:207)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120)
    at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61)
    at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
    at org.jboss.web.rewrite.RewriteValve.invoke(RewriteValve.java:466)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854)
  
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:656)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
    at java.lang.Thread.run(Thread.java:745)
   Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
    at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:993)
    at sun.reflect.GeneratedMethodAccessor440.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:344)
    at com.sun.proxy.$Proxy196.flush(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor440.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:293)
    at com.sun.proxy.$Proxy195.flush(Unknown Source)
    at com.ek.egsframework.persistence.repository.AbstractJPARepository.flush(AbstractJPARepository.java:120)
    at com.ek.egsframework.persistence.repository.AbstractJPARepository.makePersistent(AbstractJPARepository.java:79)
    at com.ek.acp.repository.ekcontrol.impl.ekDetailRepoImpl.saveekDetail(ekDetailRepoImpl.java:86)
    at sun.reflect.GeneratedMethodAccessor763.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    ... 151 more</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!-- tomcat-app-datasource.xml --&gt;
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:p="http://www.springframework.org/schema/p"
         xmlns:util="http://www.springframework.org/schema/util"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"&gt;
  
      &lt;import resource="classpath:META-INF/spring/jpa-persistence-conf.xml"/&gt;
      &lt;import resource="classpath:META-INF/spring/jdbc-persistence-conf.xml"/&gt;
  
     &lt;bean id="appDataSource"  p:username="username" p:password="password"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource"
            p:driverClassName="oracle.jdbc.driver.OracleDriver" p:url="url"/&gt;
  
      &lt;!--&lt;bean class="com.zaxxer.hikari.HikariConfig" id="hikariConfig"
            p:driverClassName="org.h2.Driver"
            p:jdbcUrl="jdbc:h2:mem:egspring;MODE=Oracle;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE;MVCC=TRUE"/&gt;--&gt;
  
      &lt;bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"
            depends-on="atomikosTransactionManager,atomikosUserTransaction"&gt;
          &lt;property name="transactionManager" ref="atomikosTransactionManager"/&gt;
          &lt;property name="userTransaction" ref="atomikosUserTransaction"/&gt;
      &lt;/bean&gt;
      &lt;bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
            init-method="init" destroy-method="close"&gt;
          &lt;property name="forceShutdown" value="false"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.J2eeUserTransaction"&gt;
          &lt;property name="transactionTimeout" value="30000"/&gt;
      &lt;/bean&gt;
  
     &lt;!-- &lt;bean id="appDataSource"
            class="com.zaxxer.hikari.HikariDataSource"&gt;
          &lt;constructor-arg ref="hikariConfig"/&gt;
      &lt;/bean&gt;--&gt;
  
      &lt;bean parent="dataSource" id="defaultJDBCDataSource"/&gt;
  
      &lt;bean id="dataSource" primary="true"
            class="com.emirates.egsframework.persistence.datasources.DatasourceRouter"
            lazy-init="true"&gt;
          &lt;property name="targetDataSources"&gt;
              &lt;map&gt;
                  &lt;entry key="RODS" value-ref="appDataSource"/&gt;
                  &lt;entry key="RWDS" value-ref="appDataSource"/&gt;
                  &lt;entry key="XADS" value-ref="appDataSource"/&gt;
              &lt;/map&gt;
          &lt;/property&gt;
          &lt;property name="defaultTargetDataSource" ref="appDataSource"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="securityDatasource"
            class="com.emirates.egsframework.persistence.datasources.DatasourceRouter"
            lazy-init="true"&gt;
          &lt;property name="targetDataSources"&gt;
              &lt;map&gt;
                  &lt;entry key="RODS" value-ref="appDataSource"/&gt;
                  &lt;entry key="RWDS" value-ref="appDataSource"/&gt;
                  &lt;entry key="XADS" value-ref="appDataSource"/&gt;
              &lt;/map&gt;
          &lt;/property&gt;
          &lt;property name="defaultTargetDataSource" ref="appDataSource"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="auditDatasource"
            class="com.emirates.egsframework.persistence.datasources.DatasourceRouter"
            lazy-init="true"&gt;
          &lt;property name="targetDataSources"&gt;
              &lt;map&gt;
                  &lt;entry key="RODS" value-ref="appDataSource"/&gt;
                  &lt;entry key="RWDS" value-ref="appDataSource"/&gt;
                  &lt;entry key="XADS" value-ref="appDataSource"/&gt;
              &lt;/map&gt;
          &lt;/property&gt;
          &lt;property name="defaultTargetDataSource" ref="appDataSource"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="entityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
            parent="abstractEntityManagerFactory" lazy-init="true"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="persistenceUnitName" value="oracle_pu"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="defaultEntityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
            parent="abstractEntityManagerFactory" lazy-init="true"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="persistenceUnitName" value="oracle_pu"/&gt;
      &lt;/bean&gt;
  
      &lt;util:map id="entityMangerFactoryMap"&gt;
          &lt;entry key="audit" value-ref="entityManagerFactory"/&gt;
          &lt;entry key="securityService" value-ref="entityManagerFactory"/&gt;
      &lt;/util:map&gt;
  
      &lt;!-- &lt;alias name="defaultEntityManagerFactory" alias="entityManagerFactory"/&gt;--&gt;
  
      &lt;util:properties id="jpaProperties"&gt;
          &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;prop key="hibernate.format_sql"&gt;true&lt;/prop&gt;
          &lt;prop key="hibernate.transaction.manager_lookup_class"&gt;
              com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
          &lt;/prop&gt;
          &lt;prop key="hibernate.transaction.factory_class"&gt;
              org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
          &lt;/prop&gt;
          &lt;!--&lt;prop key="hibernate.transaction.factory_class"&gt;org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory&lt;/prop&gt;
          &lt;prop key="hibernate.connection.autocommit"&gt;false&lt;/prop&gt;--&gt;
          &lt;!--&lt;prop key="hibernate.transaction.jta.platform"&gt;com.atomikos.icatch.jta.hibernate4.AtomikosPlatform&lt;/prop&gt;--&gt;
          &lt;!--&lt;prop key="hibernate.transaction.jta.platform"&gt;org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform&lt;/prop&gt;--&gt;
          &lt;prop key="hibernate.transaction.flush_before_completion"&gt;false&lt;/prop&gt;
          &lt;prop key="hibernate.transaction.auto_close_session"&gt;true&lt;/prop&gt;
          &lt;prop key="hibernate.current_session_context_class"&gt;jta&lt;/prop&gt;
          &lt;prop key="hibernate.connection.release_mode"&gt;auto&lt;/prop&gt;
      &lt;/util:properties&gt;
  
  &lt;/beans&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I get the following error randomly and continuously sometimes and works fine while saving other objects of same type :
   Exception occurred while saving the  as org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress</p>