Hello everyone!
I do all changes in SpringInjectionInjectRef.
But when I run program I got this message:
 

31.05.2009. 18.26.44 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader 
loadBeanDefinitions
INFO: Loading XML bean definitions from file [C:\Documents and 
Settings\10.11.2006\My 
Documents\spring25di\samples\MySpringInjectionInjectRef\beans.xml]
Exception in thread "main" 
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'injectRef' defined in file [C:\Documents and Settings\10.11.2006\My 
Documents\spring25di\samples\MySpringInjectionInjectRef\beans.xml]: Cannot 
resolve reference to bean 'myaddress' while setting bean property 'myaddress'; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'myaddress' defined in file [C:\Documents and 
Settings\10.11.2006\My 
Documents\spring25di\samples\MySpringInjectionInjectRef\beans.xml]: 
Initialization of bean failed; nested exception is 
org.springframework.beans.TypeMismatchException: Failed to convert property 
value of type [BookwormOracle] to required type [Address] for property 
'myaddress'; nested exception is java.lang.IllegalArgumentException: Cannot 
convert value of type [BookwormOracle] to required type [Address] for property 
'myaddress': no matching editors
 or conversion strategy found
        at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:274)
        at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1274)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1042)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
        at java.security.AccessController.doPrivileged(Native Method)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
        at SpringInjectRef.main(SpringInjectRef.java:10)
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'myaddress' defined in file [C:\Documents and 
Settings\10.11.2006\My 
Documents\spring25di\samples\MySpringInjectionInjectRef\beans.xml]: 
Initialization of bean failed; nested exception is 
org.springframework.beans.TypeMismatchException: Failed to convert property 
value of type [BookwormOracle] to required type [Address] for property 
'myaddress'; nested exception is java.lang.IllegalArgumentException: Cannot 
convert value of type [BookwormOracle] to required type [Address] for property 
'myaddress': no matching editors or conversion strategy found
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
        at java.security.AccessController.doPrivileged(Native Method)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
        at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:268)
        ... 12 more
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert 
property value of type [BookwormOracle] to required type [Address] for property 
'myaddress'; nested exception is java.lang.IllegalArgumentException: Cannot 
convert value of type [BookwormOracle] to required type [Address] for property 
'myaddress': no matching editors or conversion strategy found
        at 
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:395)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1313)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1042)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
        ... 20 more
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type 
[BookwormOracle] to required type [Address] for property 'myaddress': no 
matching editors or conversion strategy found
        at 
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:237)
        at 
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
        at 
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:390)
        ... 24 more
Java Result: 1
BUILD SUCCESSFUL (total time: 44 seconds)
 my bean.xml is:
 
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
"http://www.springframework.org/dtd/spring-beans.dtd";>
<beans>
 
    <!-- oracle bean used for a few examples -->
    <bean id="oracle" name="wiseworm" class="BookwormOracle"/>
    <bean id="myaddress" autowire="byName" class="BookwormOracle"/>
        
       

    <!-- injecting reference sample (using id) -->
    <bean id="injectRef" class="InjectRef">
        <property name="oracle">
            <ref local="oracle"/>
        </property>
        <property name="myaddress">
            <ref local="myaddress"/>
         </property>
    </bean>
</beans>
 
so like autowirw need I created B
public class BookwormOracle implements Oracle {
    private Encyclopedia enc;
    private Address myaddress  ;
    public void setEncyclopedia(Encyclopedia enc) {
        this.enc = enc;
    }
    public String defineMeaningOfLife() {
        return "Encyclopedia's are a waste of money - use the Internet";
    }
    public void setMyaddress(Address address){
        this.myaddress = address;
    }
}
 
I write toStryng() method in Address class, only like that I can call im in 
main clas, after getMyaddress() method. And I just dont know what tyo do?
 
Help?
Biljana
 

 


      
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Java 
EE (J2EE) Programming with Passion!" group.
To post to this group, send email to 
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to 
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to