I have a Junit test case which run a batch job. Previously It was working when I have spring batch version 2.1.2. But once I upgraded to version 4.1.1, am getting below exception
java.lang.IllegalStateException: Existing transaction detected in JobRepository. Please fix this and try again (e.g. remove @Transactional annotations from client).
I have tried removing @Transactional
from test class. But still getting an exception.I guess the error is due to two transactions. But still removal of one didn't fix the error.
Below Annotations used in the test class and it has test methods which call the method which do batch job. I have used Transactional on the test class and the test method run with SpringJUnit4ClassRunner runner. I tried with SpringRunner too.
@RunWith(SpringJUnit4ClassRunner.class) @DirtiesContext
@Transactional
This method will be called from test method. The method launched the batch job.
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public Long startExportJob(){
My spring core version is 4.3.18. Do I need to upgrade it to 5? Help me in solving this. Thanks in advance.