Announcement Announcement Module
Collapse
No announcement yet.
can't understand : Invalid property 'valuesFilePath' of bean class [$Proxy33] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • can't understand : Invalid property 'valuesFilePath' of bean class [$Proxy33]

    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
    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();
    		}
    		
    	}
    	
    }
    Please help.
    Why the PropertyPathFactoryBean can't read the property?

  • #2
    Why not just configure your job as such:

    Code:
    <property name="valuesFilePath" value="#{jobParameters['projectroot']}/abc/def/ghi/file.txt"></property>

    Comment


    • #3
      I already tried that.
      But i was geting this error

      org.springframework.expression.spel.SpelEvaluation Exception: EL1008Epos 0): Field or property 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpr essionContext'

      Comment


      • #4
        Was your bean step scoped? (scope="step")

        Comment


        • #5
          Yes of course, please see, it is there in the code above.
          I am however giving the complete configuration here
          Code:
          <batch:job id="mysimplejob" job-repository="jobRepository">
          		<batch:step id="properties_translator">
          			<batch:tasklet>
          				<batch:chunk commit-interval="10" reader="dummyReader"
          					writer="chunkWriter"></batch:chunk>
          			</batch:tasklet>
          		</batch:step>
          	</batch:job>
          	<bean id="dummyReader" class="org.mkcl.batchadmin.jobs.DummyReader"
          		scope="step">
          		<constructor-arg name="root" value="#{jobParameters['projectroot']}"></constructor-arg>
          		<property name="delegate" ref="valueReader"></property>
          		<property name="projectRoot" value="#{jobParameters['projectroot']}"></property>
          		<property name="tolang" value="#{jobParameters['tolanguages']}"></property>
          	</bean>
          	
          	<bean class="org.springframework.batch.core.scope.StepScope" />
          	
          	<bean id="valueReader" class="org.springframework.batch.item.file.FlatFileItemReader">
          		<property name="resource" value="#{jobParameters['projectroot']}/src/main/resources/value.txt"></property>
          		<property name="lineMapper" ref="lineMapper"></property>
          	</bean>
          	
          	<bean id="lineMapper" class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
          		<property name="fieldSetMapper" ref="fieldMapper"></property>
          		<property name="lineTokenizer" ref="lineTokenizer"></property>
          	</bean>
          	
          	<bean id="lineTokenizer" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
          		<property name="delimiter" value="~"></property>
          	</bean>
          	<bean id="fieldMapper" class="org.mkcl.batchadmin.jobs.ValueFieldMapper"></bean>
          	<bean id="chunkHandler"
          		class="org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean">
          		<property name="chunkWriter" ref="chunkWriter" />
          		<property name="step" ref="properties_translator" />
          	</bean>

          Comment


          • #6
            I took your ItemReader and configuration and brought it into my workspace. I did have to do a couple minor tweaks to get it to work (for example, your valueReader is not step scoped in the "complete configuration" you posted in your last post, I also pulled out the StepScope bean defined). I also filled in a couple dependencies with dummies so the job won't run successfully, but it starts which means that it's past the issue you were having. Below is what I have:
            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"
            	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">
            
            	<import resource="../launch-context.xml" />
            	
            	<job id="mysimplejob" job-repository="jobRepository" xmlns="http://www.springframework.org/schema/batch">
            		<step id="properties_translator">
            			<tasklet>
            				<chunk commit-interval="10" reader="dummyReader"
            					writer="chunkWriter"/>
            			</tasklet>
            		</step>
            	</job>
            	
            	<bean id="dummyReader" class="org.springsource.batch.reader.DummyReader" scope="step">
            		<constructor-arg name="root" value="#{jobParameters['projectroot']}"></constructor-arg>
            		<property name="delegate" ref="valueReader"></property>
            		<property name="projectRoot" value="#{jobParameters['projectroot']}"></property>
            		<property name="tolang" value="#{jobParameters['tolanguages']}"></property>
            	</bean>
            	
            	<!-- not step scoped in his configuration -->
            	<bean id="valueReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
            		<property name="resource" value="#{jobParameters['projectroot']}/src/main/resources/value.txt"></property>
            		<property name="lineMapper" ref="lineMapper"></property>
            	</bean>
            	
            	<bean id="lineMapper" class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
            		<property name="fieldSetMapper">
            			<bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
            				<property name="prototypeBeanName" ref="string"/>
            			</bean>
            		</property>
            		<property name="lineTokenizer" ref="lineTokenizer"></property>
            	</bean>
            	
            	<bean id="string" class="java.lang.String"/>
            	
            	<bean id="lineTokenizer" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
            		<property name="delimiter" value="~"></property>
            	</bean>
            	
            	<bean id="chunkWriter" class="org.springsource.batch.writer.SystemItemWriter"/>
            	
            </beans>
            One other small note, I saw that your DummyReader implements ItemReader and ItemStream. There is a utility interface, ItemStreamReader that combines the two to make your life a bit easier.

            Comment

            Working...
            X