I'm reading through the Spring reference and I'm experimenting with Spring as I go along. I'm basically using the example given in 3.3.3.1 Lookup method injection. I'm obviously missing something.
I'm using a XmlBeanFactory
My bean file is:
<beans>
<bean id="myDataSource" class="mypackage.MyDataSource" singleton="true"/>
<bean id="contactPoints" class="mypackage.ContactPoints">
<property name="myDataSource">
<ref bean="myDataSource"/>
</property>
</bean>
<bean id="customer" class="mypackage.Customer">
<property name="myDataSource">
<ref bean="myDataSource"/>
</property>
<lookup-method name="createContactPoints" bean="contactPoints"/>
</bean>
</beans>
If I take out the lookup-method all three beans are instantiated no problem. I want to return a ContactPoints object in the method createContactPoints in the Customer object.
The error I get is below. Can anyone tell me what I am doing wrong?
2004-09-24 18:42:02,938 INFO [org.springframework.beans.factory.xml.XmlBeanDefin itionReader] - <Loading XML bean definitions from (no description)>
2004-09-24 18:42:03,068 INFO [org.springframework.beans.factory.xml.XmlBeanFacto ry] - <Creating shared instance of singleton bean 'contactPoints'>
2004-09-24 18:42:03,119 INFO [org.springframework.beans.factory.xml.XmlBeanFacto ry] - <Creating shared instance of singleton bean 'myDataSource'>
2004-09-24 18:42:03,129 INFO [org.springframework.beans.factory.xml.XmlBeanFacto ry] - <Creating shared instance of singleton bean 'customer'>
Exception in thread main
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'customer' defined in (no description): Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: net.sf.cglib.proxy.CallbackFilter
java.lang.NoClassDefFoundError: net.sf.cglib.proxy.CallbackFilter
at org.springframework.beans.factory.support.CglibSub classingInstantiationStrategy.instantiateWithMetho dInjection(CglibSubclassingInstantiationStrategy.j ava:68)
at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:49)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:255)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:208)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:136)
at mypackage.TestSpringFunctions.main(TestSpringFunct ions.java:46)
Process exited with exit code 1.


Reply With Quote