I have a Request scoped(prototype) bean as a Response for a Rest Controller and getting Exception , not working
I tried spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false on the property file as suggested by the error message "Type definition error: [simple type, class org.springframework.context.expression.StandardBeanExpressionResolver]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.epic.dcms.kyc.beans.MainResponse$$EnhancerBySpringCGLIB$$82085c99[\"targetSource\"]->org.springframework.aop.target.SimpleBeanTargetSource[\"beanFactory\"]->org.springframework.beans.factory.support.DefaultListableBeanFactory[\"beanExpressionResolver\"])",
didn't work then there was a cyclic dependency and exception was thrown
@RequestScope annotation to @scope annotation change didn't solve the issue also
I notice that this exception only comes when the MainResponse used as a Response.
Bean
@RequestScope
@Component
public class MainResponse implements Serializable{
//fields and getters and setters
}
Controller class
@PostMapping("/uploadFile")
public MainResponse uploadFile(@RequestParam("file") MultipartFile file) throws FileStorageException {
String fileName = fileStorageService.storeFile(file);
response.putPayLoad(true,"fileName",fileName)
.putPayLoad("ContentType",file.getContentType())
.putPayLoad("size",file.getSize());
return response;
}
when I remove @RequestScope from MainResponse bean it just works fine, any idea how to fix this??