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:
batchContext.xml
-----------------
<job id="job1" xmlns="http://www.springframework.org/schema/batch">
<step id="step1" parent="simpleStep">
<tasklet>
<chunk reader="reader" writer="writer"/>
</tasklet>
</step>
</job>
<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"
abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="jobRepository" ref="jobRepository" />
<property name="startLimit" value="100" />
<property name="commitInterval" value="1" />
</bean>
<aop:config>
<aop:aspect id="moduleLogging" ref="logAdvice">
<aop:after
pointcut="execution( * org.springframework.batch.item.ItemWriter+.write(O bject)) and args(item)"
method="doStronglyTypedLogging" />
</aop:aspect>
<aop:aspect ref="eventAdvice">
<aop:before
pointcut="execution( * org.springframework.batch..Step+.execute(..)) and args(stepExecution)"
method="before" />
<aop:after
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" />
</aop:aspect>
</aop:config>
ApplicationContext.xml
----------------------
<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>
<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" />
JobLauncherController.java
--------------------------
JobLauncher jobLauncher = (JobLauncher)context.getBean("jobLauncher");
Job job = (Job)context.getBean("job1");
logger.info(jobLauncher);
logger.info(job);
ExitStatus exitStatus = null;
try {
JobExecution jobExecution = jobLauncher.run(
job,
new JobParametersBuilder()
.addDate("date", new Date())
.toJobParameters()
);
exitStatus = jobExecution.getExitStatus();
logger.info("status >>> "+exitStatus.getExitCode());
}
catch(JobExecutionAlreadyRunningException jobExecutionAlreadyRunningException) {
logger.info("jobExecutionAlreadyRunningException") ;
}
catch(JobRestartException jobRestartException) {
logger.info("jobRestartException");
}
catch(JobInstanceAlreadyCompleteException jobInstanceAlreadyCompleteException) {
logger.info("jobInstanceAlreadyCompleteException") ;
}
catch(JobParametersInvalidException jobParametersInvalidException){
logger.info("jobParametersInvalidException");
}
JobLauncherControllerTest
-------------------------
@Autowired
private JobLauncherController controller;
@Test
public void testHandle(){
controller.handle();
}
Can someone please tell me what I have missed out here?
Thanks
Sanjoy


Reply With Quote