title: Spring Batch - ORA-08177
body: <pre><code>org.springframework.dao.CannotSerializeTransactionException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; ORA-08177: can't serialize access for this transaction
  ; nested exception is java.sql.SQLException: ORA-08177: can't serialize access for this transaction
  
          at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:267)
          at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
          at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:660)
          at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:909)
          at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:970)
          at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:975)
          at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.createJobInstance(JdbcJobInstanceDao.java:115)
          at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:135)
          at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
          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.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:172)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
          at com.sun.proxy.$Proxy54.createJobExecution(Unknown Source)
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <p>1) Changing isolation level to ISOLATION_READ_COMMITTED</p>
  
  <pre><code>  @Bean(name="jobRepository")
  public JobRepository getJobRepository() {
      JobRepositoryFactoryBean factoryBean = new JobRepositoryFactoryBean();
      factoryBean.setDataSource(configDataSource);
      factoryBean.setTransactionManager(transactionManager);
      factoryBean.setIsolationLevelForCreate("ISOLATION_READ_COMMITTED");
      try {
          factoryBean.afterPropertiesSet();
          return factoryBean.getObject();
      } catch (Exception e) {
          log.error("JobRepository bean could not be initialized");
          throw new BatchConfigurationException(e);
      }
  }
  </code></pre>
  
  <p>2) Altered initrans for all spring batch core tables</p>
  
  <p>Update: I have already tried possible solutions provided in the other questions. However, I am still facing this problem at least once in a week in prod.</p>