when i run this code - i get org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'customEditorConfigurer' defined in class path resource [src/java/Hello.xml]: Bean class [org.springframework. beans.factory.config.CustomEditorConfigurer] not found; nested exception is java.lang.ClassNotFoundException: org/springframework/ beans/factory/config/CustomEditorConfigurer
and there is no such class as src.java.phone becauseof that now i'm getting the exception: org.springframework.beans.factory.BeanInitializationException: Could not load required type [src.java.phone] for custom editor; nested exception is java.lang.ClassNotFoundException: src.java.phone
Where is your Phone class then ? Just set this class's fully qualified type to the key of the CustomerEditor. Maybe your want to give it a capital letter : src.java.Phone. And check also the spelling of src.java.PhoneEdito[b]r[b].
Joined: Apr 26, 2006
Hi, the spelling is correct - by mistake i gave this name to my class thats why this entry in XML. And thats what i wanted to mention - that i couldn't found the phone class in the book(the code for this class is not given in the book also i'm clear that what should go in that class if i want to code it myself)
A mistake in the book. It is not Phone, but PhoneNumber. You need to understand what the property editor does. You want Spring to understand what a phone number is. So you are mapping a PhoneNumber to a PhoneEditor.
In the book, the contact bean looks like this :
If you look at Contact's phoneNumber member variable, it's a PhoneNumber. If you don't set a custom editor, Spring cannot understand how to convert "888-555-1212" to PhoneNumber instance. To make the magic happen, you tell Spring to use a PhoneEditor to interpret the value when setting a PhoneNumber.