Announcement Announcement Module
Collapse
No announcement yet.
IllegalArgumentException : JobExecution must already be saved Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IllegalArgumentException : JobExecution must already be saved

    Hello all,

    I'm trying to run a job in Spring Batch but, at the moment of launching, I get the following exception:

    Code:
    java.lang.IllegalArgumentException: JobExecution must already be saved
    	at org.springframework.util.Assert.notNull(Assert.java:112)
    	at org.springframework.batch.core.repository.dao.MapJobExecutionDao.updateJobExecution(MapJobExecutionDao.java:89)
    	at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:155)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy13.update(Unknown Source)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:329)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:680)
    Exception in thread "jobLauncherTaskExecutor-1" java.lang.IllegalArgumentException: JobExecution must already be saved
    	at org.springframework.util.Assert.notNull(Assert.java:112)10:22:39,986 DEBUG http-bio-8080-exec-6 datasource.DataSourceUtils:332 - Returning JDBC Connection to DataSource
    
    	at org.springframework.batch.core.repository.dao.MapJobExecutionDao.updateJobExecution(MapJobExecutionDao.java:89)
    	at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:155)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy13.update(Unknown Source)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:329)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
    10:22:39,986 DEBUG http-bio-8080-exec-6 datasource.DataSourceUtils:332 - Returning JDBC Connection to DataSource
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:680)
    Truth is I'm quite at a loss trying to figure out what's going on. I'm pretty sure it must be something related to my configuration...

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:batch="http://www.springframework.org/schema/batch"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
     	http://www.springframework.org/schema/beans/spring-beans.xsd
     	http://www.springframework.org/schema/batch 
    	http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
    	http://www.springframework.org/schema/aop 
    	http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    	http://www.springframework.org/schema/tx 
    	http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    	
    	
    	<!-- transaction manager associated to the job repository .-->
    	<bean id="jobRepository-transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" /> 
    	
    	<!-- job repository associated to the job launcher. -->
    	<bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
    		<property name="transactionManager" ref="jobRepository-transactionManager" />
    	</bean>
    	
    	<!-- job launcher. -->
    	<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
    		<property name="jobRepository" ref="jobRepository" />
    	</bean> 
    
    	<!-- define the BULK IMPORT job. -->
    	<batch:job id="bulkImport">
    		<batch:step id="bulkImportSingleStep">
    			<batch:tasklet>
    				<batch:chunk reader="bulkImportReader" processor="bulkImportCompositeProcessor" writer="commonWriter" commit-interval="2" />
    			</batch:tasklet>
    		</batch:step>
    	</batch:job>
    
    	<bean id="bulkImportCompositeProcessor" class="org.springframework.batch.item.support.CompositeItemProcessor">
    		<property name="delegates">
    			<list>
    				<bean class="com.playence.platform.processors.BulkImportBasicSteps" />
    				<bean class="com.playence.platform.processors.FileSystemUploadProcessor" />
    				<bean class="com.playence.platform.processors.TranscriptionExtractionProcessor" />
    				<bean class="com.playence.platform.processors.IndexingProcessor" />
    			</list>
    		</property>
    	</bean>
    	
    	<!-- bulk import specific beans. -->
    	<!-- Virtual File System manager & reader. -->
    	<bean id="bulkImportManager" class="com.playence.platform.io.BulkImportManager">
    		<constructor-arg>
    			<value>localFile</value>
    		</constructor-arg>
    	</bean>
    	<bean id="bulkImportReader" class="com.playence.platform.readers.BulkImportReaderImpl" scope="step">
    		<property name="vfsManager">
    			<ref bean="bulkImportManager" />
    		</property>
    		<property name="protocol" value="localFile"/>
    		<property name="pathToLoad" value="#{jobParameters['pathToLoad']}"/>
    	</bean>
    	
    	<!-- general beans. -->
    	<!-- writer. -->
    	<bean id="commonWriter" class="com.playence.platform.writers.Writer"/>
    	<!-- transcriptionExtractionProcessor -->
    	<bean id="transcriptionExtractionProcessor" class="com.playence.platform.processors.TranscriptionExtractionProcessor"/>
    
    	<!-- storage beans. -->
    	<bean id="fileSystemStorageService" class="com.playence.platform.uploaders.FileSystemUploader">
    	</bean>
    
    </beans>
    I would greatly appreciate if anyone could point at what's wrong here. Perhaps it is related to some issue with the database?

    Thanks, and regards,
    cR.

  • #2
    My gut feeling would be that it is due to the fact that you've named the transaction manager jobRepository-transactionManager instead of just transactionManager. This prevents the step from being autowired with the transaction manager. I took your configuration and ran it as is (swapping in my own reader/processor/writer) and with the transaction manager named as you did, I got the exception that the transactionManager was not being set on the step. Once I renamed the transaction manager, the job completed fine.

    Comment

    Working...
    X