Closed
Description
Ievgen Starodiedov opened SPR-14303 and commented
The following bean declaration causes BeanCreationException:
<bean id="submissionDateFormatter" class="java.time.format.DateTimeFormatter" factory-method="ofPattern">
<constructor-arg name="pattern" value="dd-MMM-yyyy HH:mm"/>
<constructor-arg name="locale" value="#{T(java.util.Locale).UK}"/>
</bean>
(!) Path to file with bean definition is partially hidden according to NDA (!)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'submissionDateFormatter' defined in file [%path%\target\classes\spring\integration\elections-submission-service-int.xml]: No matching factory method found: factory method 'ofPattern(String,Locale)'. Check that a method with the specified name and arguments exists and that it is static.
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:551) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1113) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1008) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:505) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) ~[spring-context-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) ~[spring-context-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at com.ubs.f35.core.server.container.ContainerStart.main(ContainerStart.java:25) ~[core-server-container-3.0.1.jar:na]
The same declaration without constructor argument names causes no exception though
<bean id="submissionDateFormatter" class="java.time.format.DateTimeFormatter" factory-method="ofPattern">
<constructor-arg value="dd-MMM-yyyy HH:mm"/>
<constructor-arg value="#{T(java.util.Locale).UK}"/>
</bean>
Spring version - 4.1.0.RELEASE
Java version - 1.8.0_05
Issue Links:
- Unique XML-specified constructor not accepted in case of unresolvable name [SPR-13987] #18559 Unique XML-specified constructor not accepted in case of unresolvable name ("duplicates")