Hi everyone,
This is my simple reader configuration.
I am passing projectroot as jobParameter.
What i have to do is pass projectRoot as jobParameter.
And then I need to append somedata for the actual file path.
e.g if projectroot="E:/myproj"
then i need to append "abc/def/ghi/file.txt"
so that the absolute path for the file is "E:/myproj/abc/def/ghi/file.txt"
from where the FlatFileItemReader will read the data.
I tried hard coding, its working fine.
but when I am trying to use it this way, I am getting the Error
Invalid property 'valuesFilePath' of bean class [$Proxy33]
can't understand why is it so?
Code:<bean id="dummyReader" class="org.mkcl.batchadmin.jobs.DummyReader" scope="step"> <property name="delegate" ref="valueReader"></property> <property name="projectRoot" value="#{jobParameters['projectroot']}"></property> <property name="valuesFilePath" value="#{jobParameters['projectroot']}"></property> <property name="keysFilePath" value="#{jobParameters['projectroot']}"></property> </bean> <bean id="dummyWriter" class="org.mkcl.batchadmin.jobs.DummyWriter"> </bean> <bean class="org.springframework.batch.core.scope.StepScope" /> <bean id="valueReader" class="org.springframework.batch.item.file.FlatFileItemReader" depends-on="dummyReader"> <property name="resource"> <bean class="org.springframework.beans.factory.config.PropertyPathFactoryBean"> <property name="targetBeanName" value="dummyReader"></property> <property name="propertyPath" value="valuesFilePath"></property> </bean> </property> <property name="lineMapper" ref="lineMapper"></property> </bean>
This is DummyReader
Please help.Code:public class DummyReader implements ItemReader<String>, ItemStream { String projectRoot; String valuesFilePath; String keysFilePath; private ItemReader<String> delegate; /** * @return the valuesFilePath */ public String getValuesFilePath() { return valuesFilePath; } /** * @param valuesFilePath the valuesFilePath to set */ public void setValuesFilePath(String valuesFilePath) { this.valuesFilePath = valuesFilePath+File.separator+"abc"+File.separator+"def"+File.separator+"ghi"+File.separator+"value.txt";; } /** * @return the keysFilePath */ public String getKeysFilePath() { return keysFilePath; } /** * @param keysFilePath the keysFilePath to set */ public void setKeysFilePath(String keysFilePath) { this.keysFilePath = keysFilePath+File.separator+"abc"+File.separator+"def"+File.separator+"ghi"+File.separator+"key.txt"; } /** * @return the projectRoot */ public String getProjectRoot() { return projectRoot; } /** * @param projectRoot the projectRoot to set */ public void setProjectRoot(String projectRoot) { this.projectRoot = projectRoot; } /** * @return the delegate */ public ItemReader<String> getDelegate() { return delegate; } /** * @param delegate the delegate to set */ public void setDelegate(ItemReader<String> delegate) { this.delegate = delegate; } @Override public String read() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception{ String s=delegate.read(); System.out.println("Reading..."+projectRoot); return s; } @Override public void open(ExecutionContext executionContext) throws ItemStreamException { System.out.println("Method Called"); if (this.delegate instanceof ItemStream) { ((ItemStream)this.delegate).open(executionContext); } } @Override public void update(ExecutionContext executionContext) throws ItemStreamException { if (this.delegate instanceof ItemStream) { ((ItemStream)this.delegate).update(executionContext); } } @Override public void close() throws ItemStreamException { if (this.delegate instanceof ItemStream) { ((ItemStream)this.delegate).close(); } } }
Why the PropertyPathFactoryBean can't read the property?


Reply With Quote
pos 0): Field or property 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpr essionContext'
