You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With value referenced from property file in XML configuration, setter selection can be random in case of overloaded setter methods (e.g. on SimpleClientHttpRequestFactory)
#32329
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.
Summary
With value referenced from property file in XMLConfig, if a bean-defined class has an overloaded setter, an exception may be thrown at runtime.
I checked the logs and found that the wrong setter was used.
Specifically, I found that the setter was changing each time the application was launched.
This behaviour occurs in XMLConfig
I found this behaviour in the bean definition of SimpleClientHttpRequestFactory.
Here is an example of a Bean definition.
SimplyClientHttpRequestFactory has overload setter of Duration and int such as setConnectTimeout method, setReadTimeout method.
Warning message:
2024-02-26 10:22:16,302 [main] [customerId: ] [domainId: ] [sessionId: ] WARN o.s.w.c.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beanId' defined in class path resource [spring/service-context.xml]: Failed properties: Failed to convert property value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'connectTimeout'; Cannot convert value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'connectTimeout': no matching editors or conversion strategy found; Failed to convert property value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'readTimeout'; Cannot convert value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'readTimeout': no matching editors or conversion strategy found
Error message:
2024-02-26 10:22:16,329 [main] ERROR o.s.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beanId' defined in class path resource [spring/service-context.xml]: Failed properties: Failed to convert property value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'connectTimeout'; Cannot convert value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'connectTimeout': no matching editors or conversion strategy found; Failed to convert property value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'readTimeout'; Cannot convert value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'readTimeout': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1720)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1434)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:959)
Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed properties: Failed to convert property value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'connectTimeout'; Cannot convert value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'connectTimeout': no matching editors or conversion strategy found; Failed to convert property value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'readTimeout'; Cannot convert value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'readTimeout': no matching editors or conversion strategy found
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:135)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:79)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1717)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1434)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Affects: 6.1.4
Summary
With value referenced from property file in XMLConfig, if a bean-defined class has an overloaded setter, an exception may be thrown at runtime.
I checked the logs and found that the wrong setter was used.
Specifically, I found that the setter was changing each time the application was launched.
This behaviour occurs in XMLConfig
I found this behaviour in the bean definition of SimpleClientHttpRequestFactory.
Here is an example of a Bean definition.
SimplyClientHttpRequestFactory has overload setter of Duration and int such as setConnectTimeout method, setReadTimeout method.
Warning message:
2024-02-26 10:22:16,302 [main] [customerId: ] [domainId: ] [sessionId: ] WARN o.s.w.c.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beanId' defined in class path resource [spring/service-context.xml]: Failed properties: Failed to convert property value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'connectTimeout'; Cannot convert value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'connectTimeout': no matching editors or conversion strategy found; Failed to convert property value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'readTimeout'; Cannot convert value of type 'java.lang.Integer' to required type 'java.time.Duration' for property 'readTimeout': no matching editors or conversion strategy found
Error message:
The text was updated successfully, but these errors were encountered: