I have recently started using spring-batch. I am trying to get the file name from Job Parameters that I can use for writer. So I am defining my bean definition for writer as scope="test".

Code:
	<bean id="itemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step">
	    <property name="resource" value="#{jobParameters['OUTFILE']}" />
	    <property name="lineAggregator">
	        <bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
	            <property name="delimiter" value=","/>
	            <property name="fieldExtractor">
	                <bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
	                    <property name="names" value="policyId,version,vehicleNumber,coverageGroup"/>
	                </bean>
	            </property>
	        </bean>
	    </property>
	</bean>
The code for launcher is
Code:
	public void testLaunchJob() throws Exception {
		JobParameters jobParameters = new JobParametersBuilder().addString("owner","NAME").addDate("currentTime", new Date()).addString("OUTFILE", "file:target/test-outputs/output2.txt").toJobParameters();
		sampleJobLauncher.run(job, jobParameters);
	}
I made these changes based on few threads in the spring-batch forum and chapter-5 of spring-batch documentation. But when I run the job, I get the following errors

Code:
Caused by: java.io.FileNotFoundException: class path resource [#{jobParameters['OUTFILE']}] cannot be resolved to URL because it does not exist
	at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:162)
	at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:47)
	at org.springframework.batch.item.file.FlatFileItemWriter.getOutputState(FlatFileItemWriter.java:337)
	... 55 more
Any insights regarding this issue would be of great help.

Thanks,
Praveen