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
{{ message }}
Repository navigation
Unique XML-specified constructor not accepted in case of unresolvable name [SPR-13987] #18559
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myExecutor' defined in class path resource [applicationContext-test.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [int]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
Class ScheduledThreadPoolExecutor has only one 1-arg constructor:
public ScheduledThreadPoolExecutor(int corePoolSize)
If not a bug, I would suggest improving the error message and the documentation in spring-beans.xsd.
Looks like this is because the java.util.concurrent.ScheduledThreadPoolExecutor (like all of the JDK's rt.jar) is not compiled with -parameters, so we can't resolve the parameter name... However, unfortunately, we insist on resolving the name even in cases where the constructor specification is unique in any case! And indeed, the wording of the exception message should be improved, but for this particular case, the configuration should actually just get accepted and work fine at runtime.
Why name is a problem for resolving if index specified?
Why constructor resolver doesn't understand that if I specify only one argument I want constructor with one argument? For example this doesn't work:
<bean id="blockingQueue" class="java.util.concurrent.ArrayBlockingQueue" c:capacity="100" />
This class has three constructors with one, two and three arguments.
Activity
spring-projects-issues commentedon Feb 26, 2016
Juergen Hoeller commented
Looks like this is because the
java.util.concurrent.ScheduledThreadPoolExecutor(like all of the JDK'srt.jar) is not compiled with-parameters, so we can't resolve the parameter name... However, unfortunately, we insist on resolving the name even in cases where the constructor specification is unique in any case! And indeed, the wording of the exception message should be improved, but for this particular case, the configuration should actually just get accepted and work fine at runtime.Juergen
spring-projects-issues commentedon Mar 18, 2016
Juergen Hoeller commented
I've revised our
ConstructorArgumentValuesholder to leniently allow for matches if the required name is not resolvable.Juergen
spring-projects-issues commentedon May 23, 2016
Guram Savinov commented
<bean id="blockingQueue" class="java.util.concurrent.ArrayBlockingQueue" c:capacity="100" />
This class has three constructors with one, two and three arguments.
spring-projects-issues commentedon Jun 9, 2016
Juergen Hoeller commented
As per these changes in 4.3 RC1, your scenarios should work fine. Have you tried RC1, or even better RC2 or the latest
4.3.0.BUILD-SNAPSHOT?