Results 1 to 3 of 3

Thread: Newbie: Can't get lookup injection working

  1. #1

    Default Newbie: Can't get lookup injection working

    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.

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    You need to add CGLib jar to your classpath.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3

    Default

    Much appreciated!

Similar Threads

  1. Replies: 1
    Last Post: Oct 6th, 2005, 10:32 AM
  2. Testing a Class that uses lookup-method injection
    By akehurst in forum Container
    Replies: 15
    Last Post: Sep 22nd, 2005, 07:24 AM
  3. Replies: 5
    Last Post: Jun 29th, 2005, 03:49 PM
  4. Replies: 1
    Last Post: Jun 12th, 2005, 08:46 AM
  5. Replies: 7
    Last Post: Oct 18th, 2004, 12:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •