Apologies if this question has been answered before on the forum. If so, please point me to the thread as I have been unable to find it.
Spring appears to be unable to find constructors with arguments and access modifier less than public when default public constructor is present.
Consider the class:
package test;
public SimpleBean {
public SimpleBean() {}
private SimpleBean(String x) {}
}
Context configuration:
<bean id="simpleBean" class="test.SimpleBean">
<constructor-arg value="test" />
</bean>
Spring throws the following exception:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'simpleBean' defined in class path resource [test/Test-context.xml]: 1 constructor arguments specified but no matching constructor found in bean 'simpleBean' (hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)
Everything works fine (no exceptions) if
1. The public default constructor is removed or its signature is changed to accept some argument.
2. The access modifier of the zero argument constructor is anything less than public.
The class's design notwithstanding, any ideas why Spring throws this exception?


Reply With Quote