I am working on a gigaspace xap application which uses spring under the hood. The jini transaction manager provided by gigaspaces does not support serializable.
I have a class which uses spring-batch to process a file. Below is how it is invoking the job
public class FileProcessor implements BasicFileProcessor {
@Value("${feeddownload.basedir}")
private String baseDir;
@Autowired
private JobLauncher jobLauncher;
@Autowired
private Job cmJob;
@Autowired
private MapJobRepositoryFactoryBean repositoryFactoryBean;
@Override
public void process(RiskRunCompletion riskRunCompletion, VersionedSliceName versionedSliceName, GigaSpace gigaSpace) {
Transaction tx = gigaSpace.getCurrentTransaction();
try {
//Adding current time to the parameter, to enable multiple times calling job with same parameters
long currentTimeInMillis = System.currentTimeMillis();
JobParameter currentTimeInMillinsParam = new JobParameter(currentTimeInMillis);
Map parameterMap = new LinkedHashMap();
addDirectoryParams(valuationSliceRun, parameterMap);
parameterMap.put(CURRENT_TIME, currentTimeInMillinsParam);
JobParameters paramMap = new JobParameters(parameterMap);
JobExecution cmExecution = launchJobWithParameters(paramMap);
for (Throwable t : cmExecution.getAllFailureExceptions()) {
throw new RuntimeException(t);
}
} catch (Exception e) {
throw new RuntimeException("Exception during batch job", e);
} finally {
repositoryFactoryBean.clear();
}
}
private JobExecution launchJobWithParameters(JobParameters paramMap) throws Exception {
return jobLauncher.run(cmJob, paramMap);
}
}
The process method is invoked from a different class as below
public class FileBasedProcessingEventListener implements ApplicationContextAware {
@Value("${feeddownload.basedir}")
private String baseDir;
@Autowired
private BasicFileProcessor cmProcessor;
@Autowired
private FileBasedProcessingExceptionHandler fileBasedProcessingExceptionHandler;
public void handle(FileBasedProcessingEvent fileBasedProcessingEvent, GigaSpace gigaSpace) throws IOException {
LOGGER.info("Processing file based processing event : " + fileBasedProcessingEvent);
createLockFiles(fileBasedProcessingEvent);
handleEvent(fileBasedProcessingEvent, gigaSpace);
}
private void handleEvent(FileBasedProcessingEvent fileBasedProcessingEvent, GigaSpace gigaSpace) {
Transaction tx = gigaSpace.getCurrentTransaction();
cmProcessor.process(fileBasedProcessingEvent.getRiskRunCompletion(), versionedSliceName, gigaSpace);
}
}
Handle method is called from the framework. Now i am not sure why i am getting the exception as below
Caused by: org.springframework.transaction.InvalidIsolationLevelException: Jini Transaction Manager does not support serializable isolation level
at org.openspaces.core.transaction.manager.AbstractJiniTransactionManager.applyIsolationLevel(AbstractJiniTransactionManager.java:271)
at org.openspaces.core.transaction.manager.AbstractJiniTransactionManager.doJiniBegin(AbstractJiniTransactionManager.java:251)
at org.openspaces.core.transaction.manager.AbstractJiniTransactionManager.doBegin(AbstractJiniTransactionManager.java:207)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
None of the classes are marked as transactional, i am not sure why TransactionInterceptor is being invoked when i have not marked any class or any method as transaction it should not be of any concern. I also used Transaction tx = gigaSpace.getCurrentTransaction(); to check that transaction is not active it comes as null only
i am confused when none of the classes are marked as transactional why is spring trying to invoke this method under transaction
Looks like Gigaspaces transaction manager is based upon Spring transaction management infrastructure as can be inferred from the documentation here - so if you are using Gigaspaces transaction API then you are using Spring transaction management. Also worth looking is any transaction manager configuration inside xml configuration files which would point the exact transaction manager class.