Skip to content

SpelEvaluationException: EL1021E: A problem occurred whilst attempting to access the property 'input' #Documentation #4202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dlehammer opened this issue Oct 3, 2022 · 3 comments
Labels
in: documentation status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter type: bug

Comments

@dlehammer
Copy link

Bug description
Attempting to follow the Spring Batch Integration Configuration guide results in exception:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1021E: A problem occurred whilst attempting to access the property 'input': 'Invalid property 'input' of bean class [org.springframework.batch.core.scope.context.StepContext]: Bean property 'input' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?'
	at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:209)
	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:104)
	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:91)
	at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:55)
	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:91)
	at org.springframework.expression.spel.ast.Indexer.getValueRef(Indexer.java:134)
	at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:70)
	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:91)
	at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:112)
	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:273)
	at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:167)
	... 29 common frames omitted
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'input' of bean class [org.springframework.batch.core.scope.context.StepContext]: Bean property 'input' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
	at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:627)
	at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:617)
	at org.springframework.batch.core.scope.StepScope.resolveContextualObject(StepScope.java:91)
	at org.springframework.beans.factory.config.BeanExpressionContext.containsObject(BeanExpressionContext.java:54)
	at org.springframework.context.expression.BeanExpressionContextAccessor.canRead(BeanExpressionContextAccessor.java:39)
	at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:198)
	... 39 common frames omitted

Environment
Spring Batch v4.3.7

$ java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)

Steps to reproduce
Follow the guide.

Expected behavior
The guide results in runnable proof-of-concept :)

Minimal Complete Reproducible example
N/A

Known workaround
Rename input.file.name to ex: input_file_name

@dlehammer dlehammer added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Oct 3, 2022
@fmbenhassine
Copy link
Contributor

Thank you for raising this. I created #4205 to improve the way how samples are verified before being included in the documentation.

@fmbenhassine fmbenhassine added in: documentation and removed status: waiting-for-triage Issues that we did not analyse yet labels Oct 24, 2022
@fmbenhassine
Copy link
Contributor

How did you get that exception? input.file.name is a valid job parameter name, and the sample in the section you mentioned is correct, ie the same job parameter name is used in the flow definition as well as in the reader definition:

@Bean
public FileMessageToJobRequest fileMessageToJobRequest() {
    FileMessageToJobRequest fileMessageToJobRequest = new FileMessageToJobRequest();
    fileMessageToJobRequest.setFileParameterName("input.file.name");
    fileMessageToJobRequest.setJob(personJob());
    return fileMessageToJobRequest;
}

// [...]

@Bean
@StepScope
public ItemReader sampleReader(@Value("#{jobParameters[input.file.name]}") String resource) {
    FlatFileItemReader flatFileItemReader = new FlatFileItemReader();
    flatFileItemReader.setResource(new FileSystemResource(resource));
    return flatFileItemReader;
}

According to the error message you shared :Invalid property 'input' of bean class [org.springframework.batch.core.scope.context.StepContext], the job parameter is being fetched from the step execution context, not the job parameters set. Are you sure you are following the guide step by step?

Some examples in the documentation as just code snippets that you need to adapt anyway, but unless I missed something, the sample in that section looks good to me.

@fmbenhassine fmbenhassine added the status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter label Apr 3, 2023
@dlehammer
Copy link
Author

Hi @fmbenhassine,

Sounds plausible, closing as I was unable to locate the original project demonstrating the symptom :)

@dlehammer dlehammer closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: documentation status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter type: bug
Projects
None yet
Development

No branches or pull requests

2 participants