Announcement Announcement Module
Collapse
No announcement yet.
How to "lookup Method injection" ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to "lookup Method injection" ?

    Hi everyone !

    I'm starting with Spring , and i'm trying every features of the spring core.

    Right now i'm stuck with Lookup method injection (3.3.4.1), i let you consult the short paragraph about
    just here :http://static.springframework.org/sp...s.html#d0e1058


    Code:
    <bean id="DataSource" class="com.AO.DAO.DAOImpl" autowire="byType" init-method="connect">
    	<lookup-method name="createResource" bean="File" />
    </bean>
    	
    <!-- This bean is abstract, it can't be instantiated as such -->
    <bean id="Resources" abstract="true" class="com.AO.resources.Resources" singleton="false">
    	<property name="read"><value>true</value></property>
    	<property name="write"><value>true</value></property>
    </bean>
    	
    <bean id="File" parent="Resources">
    	<property name="read"><value>true</value></property>	
    	<property name="id"><value>666</value></property>		
    </bean>
    In com.AO.DAO.DAOImpl, i have the following code :
    Code:
    protected IResources createResource&#40;&#41; &#123;	return null;	&#125;
    When i launch my app i got this error :
    2005-06-23 11:39:12,296 INFO [org.springframework.beans.factory.xml.XmlBeanFacto ry] - <Creating shared instance of singleton bean 'DataSource'>
    Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'DataSource' defined in resource loaded through InputStream: 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:69)
    at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:53)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:322)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at com.AO.demo.App.main(App.java:35)

    Well, what i am doing wrong ? Everything is here, but it failed in a very strange way...
    Something appears to be missing but i have included Spring-beans.jar and spring-core.jar, and this features should belong to those "jars"...


    Belaran,

    :?:

  • #2
    Hiya

    You need to reference the cglib.jar file too, as this feature relies on classes from that library.

    Ciao
    .NET Guy

    Comment


    • #3
      Hiya

      'Reference'? Shucks, I have been doing way too much .NET lately :?

      What I meant to write was that you have to ensure that the cglib.jar is available on your CLASSPATH. From the looks of the stacktrace, it isn't.

      java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
      Ciao
      .NET Guy

      Comment


      • #4
        Of course !

        Work perfectly now

        thanks++

        Comment

        Working...
        X