I'm having issues getting the getBean(string, object[]) method of the bean factory to work correctly. Basically what I'm trying to do is setup a proxy factory that returns prototype instances with arguments that are passed in.
I think I got the xml correct, but I get the following error:
Error creating bean with name 'myBean' defined in class path resource [beans.xml]: 8 constructor arguments specified but no matching constructor found in bean 'myBean' (hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)
Here is a snippet from my XML:
here is the MyBeanFactory ClassCode:<bean id="aopLogger" class="LoggingAspect" /> <bean id="myBean" class="org.springframework.aop.framework.ProxyFactoryBean" scope="prototype"> <property name="proxyInterfaces"><value>MyBeanInterface</value></property> <property name="target"> <bean id="myBeanFactory" class="...MyBeanFactory" scope="prototype" factory-method="createMyBean"> <constructor-arg index="0"><value>""</value></constructor-arg> <constructor-arg index="1"><value>""</value></constructor-arg> <constructor-arg index="2"><value>""</value></constructor-arg> <constructor-arg index="3"><value>null</value></constructor-arg> <constructor-arg index="4"><list></list></constructor-arg> <constructor-arg index="5"><value>""</value></constructor-arg> <constructor-arg index="6"><value>""</value></constructor-arg> <constructor-arg index="7"><value>""</value></constructor-arg> </bean> </property> <property name="interceptorNames"> <list> <value>aopLogger</value> </list> </property> </bean>
and the code that calls it:Code:public class MyBeanFactory { public static MyBeanInterface createMyBean(UUID id, String name, String description, IVersion version, List<IDependency> dependencies, String company, String url, String copyright) { return new MyBeanImpl(id, name, description, version, dependencies, company, url, copyright); } }
I'm a little confused here... The method takes 8 args, I've used index to specify which ones are which, but it still gives me that error. I have also tried to identify the types, but that didn't do anything. I've also tried to create a reference of the bean directly without using my own factory class, but had the same issues with that.Code:return (MyBeanImpl) context.getBean("myBean", new Object[] { id, name, description, version, dependencies, company, url, copyright });
Any ideas?
Thanks.


Reply With Quote
