Create new output file using FlatFileItemWriter in spring-batch -


i have simple spring batch job - read file line line, input string, , write output. output file contains every line of input plus processing status line (success/failure.) reads file from: <dir>/<inputfolder>/<inputfilename> , writes processed output <dir>/<outputfolder>/<inputfilename> these values passed jobparameters
file reader so:

<bean id="itemreader" class="org.springframework.batch.item.file.flatfileitemreader" scope="step">         <property name="resource" value="file:#{jobparameters['cwd']}/#{jobparameters['inputfolder']}/#{jobparameters['inputfile']}" />          <property name="linemapper">           <bean class="org.springframework.batch.item.file.mapping.defaultlinemapper">              <property name="linetokenizer">               <bean class="org.springframework.batch.item.file.transform.delimitedlinetokenizer">                 <property name="delimiter" value="," />               </bean>             </property>             <property name="fieldsetmapper" >               <bean class="org.springframework.batch.item.file.mapping.passthroughfieldsetmapper" />             </property>           </bean>         </property>     </bean> 

item writer so:

<bean id="itemwriter" class="org.springframework.batch.item.file.flatfileitemwriter" scope="step" >         <property name="resource" value="#{jobparameters['cwd']}/#{jobparameters['outputfolder']}/#{jobparameters['inputfile']}" />         <property name="lineaggregator">             <bean class="org.springframework.batch.item.file.transform.passthroughlineaggregator" />         </property>     </bean>   

when run batch job, reader reads file properly, processor job filenotfound exception thrown itemwriter

2014/06/27 18-02-31,168:out:error[encountered error executing step] org.springframework.batch.item.itemstreamexception: not convert resource file: [class path resource [s:/temp/seller-optin-batch/output/sellerstooptin_test.txt]]     @ org.springframework.batch.item.file.flatfileitemwriter.getoutputstate(flatfileitemwriter.java:374)     @ org.springframework.batch.item.file.flatfileitemwriter.open(flatfileitemwriter.java:314)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ...     caused by: java.io.filenotfoundexception: class path resource [s:/temp/seller-optin-batch/output/sellerstooptin_test.txt] cannot resolved url because not exist         @ org.springframework.core.io.classpathresource.geturl(classpathresource.java:179)         @ org.springframework.core.io.abstractfileresolvingresource.getfile(abstractfileresolvingresource.java:48)         @ org.springframework.batch.item.file.flatfileitemwriter.getoutputstate(flatfileitemwriter.java:371)         ... 58 more     2014/06/27 18-02-31,168:err:error[encountered error executing step]      [org.springframework.batch.item.file.flatfileitemwriter.getoutputstate threw org.springframework.batch.item.itemstreamexception: not convert resource file: [class path resource [s:/temp/seller-optin-batch/output/sellerstooptin_test.txt]]]     batch execution failed! 

everytime batch job runs, output file not exist yet. itemwriter has create it. not possible using flatfileitemwriter ?

adding 'file://' prefix solved problem. @lucabassoricci.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -