Announcement Announcement Module
No announcement yet.
org.springframework.transaction.InvalidIsolationLe velException Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • org.springframework.transaction.InvalidIsolationLe velException

    Hello Everyone,

    I am new to Spring Batch. I have tried to create a simple job using the examples given in sample applications. I want to run it in a web container. But it seems that my job is not running due to InvalidIsolationLevelException. Whenever I run my test I get this exception.

    org.springframework.transaction.InvalidIsolationLe velException: Standard JPA does not support custom isolation levels - use a special JpaDialect for your JPA implementation

    These are set-up I have done to run my batch job:


    <job id="job1" xmlns="">
    <step id="step1" parent="simpleStep">
    <chunk reader="reader" writer="writer"/>

    <bean id="reader" class="com.mega.neo.batch.ExampleItemReader"/>
    <bean id="writer" class="com.mega.neo.batch.ExampleItemWriter" />

    <bean id="simpleStep"
    class="org.springframework.batch.core.step.item.Si mpleStepFactoryBean"
    <property name="transactionManager" ref="transactionManager" />
    <property name="jobRepository" ref="jobRepository" />
    <property name="startLimit" value="100" />
    <property name="commitInterval" value="1" />

    <aop:aspect id="moduleLogging" ref="logAdvice">
    pointcut="execution( * org.springframework.batch.item.ItemWriter+.write(O bject)) and args(item)"
    method="doStronglyTypedLogging" />
    <aop:aspect ref="eventAdvice">
    pointcut="execution( * org.springframework.batch..Step+.execute(..)) and args(stepExecution)"
    method="before" />
    pointcut="execution( * org.springframework.batch..Step+.execute(..)) and args(stepExecution)"
    method="after" />
    <aop:after-throwing throwing="t"
    pointcut="execution( * org.springframework.batch..Step+.execute(..)) and args(stepExecution)"
    method="onError" />


    <import resource="classpath:/META-INF/spring/batchContext.xml" />

    <bean id="jobLauncher" class="org.springframework.batch.core.launch.suppo rt.SimpleJobLauncher">
    <property name="jobRepository" ref="jobRepository" />
    <property name="taskExecutor" ref="executor" />

    <bean id="jobRepository" class="org.springframework.batch.core.repository.s upport.JobRepositoryFactoryBean"
    p:dataSource-ref="dataSource" p:transactionManager-ref="transactionManager"
    p:tablePrefix="batch_" />

    <bean id="logAdvice" class="com.mega.neo.batch.advice.ProcessorLogAdvic e" />

    <bean id="eventAdvice" class="com.mega.neo.batch.advice.StepExecutionAppl icationEventAdvice" />

    JobLauncher jobLauncher = (JobLauncher)context.getBean("jobLauncher");
    Job job = (Job)context.getBean("job1");;;

    ExitStatus exitStatus = null;

    try {
    JobExecution jobExecution =
    new JobParametersBuilder()
    .addDate("date", new Date())

    exitStatus = jobExecution.getExitStatus();"status >>> "+exitStatus.getExitCode());
    catch(JobExecutionAlreadyRunningException jobExecutionAlreadyRunningException) {"jobExecutionAlreadyRunningException") ;
    catch(JobRestartException jobRestartException) {"jobRestartException");
    catch(JobInstanceAlreadyCompleteException jobInstanceAlreadyCompleteException) {"jobInstanceAlreadyCompleteException") ;
    catch(JobParametersInvalidException jobParametersInvalidException){"jobParametersInvalidException");

    private JobLauncherController controller;

    public void testHandle(){



    Can someone please tell me what I have missed out here?


  • #2
    we need to know more about your environment to diagnose the problem:
    - full stack trace of the InvalidIsolationLevelException
    - the configuration configuration of your JPA environment (provider, database, etc)

    Spring Batch uses the SERIALIZABLE isolation level to create job executions, this can the cause.

    and please, use [ CODE ] tags.


    • #3
      Hello arno,

      Thank you very much for reply. I have managed to stop this exception by using the below configuration:

      <bean id="jobRepository" class="" 
          	p:dataSource-ref="dataSource" p:transactionManager-ref="transactionManager" p:tablePrefix="BATCH_">
          	<property name="isolationLevelForCreate" value="ISOLATION_DEFAULT"/>
      I am using MySQL and Hibernate. Could you please tell me whether it is right configuration. Sorry for not using CODE tag.



      • #4
        ok, so you got rid of the exception by loosening the isolation level (which is usually READ_COMMITTED by default). This is ok if you're not launching a same job (too) concurrently. You can get the full explanation about this setting here: