Results 1 to 2 of 2

Thread: TypeMismatchException - java.lang.Character

  1. #1
    Join Date
    Feb 2005
    Posts
    1

    Default TypeMismatchException - java.lang.Character

    I'm attempting to configure a bean within spring using the following bean definition where 'entryIndicator' is defined as a java.lang.Character instance variable on com.test.EntryBean, with the necessary getter/setter:

    <bean id="docTypeBean0" class="com.test.EntryBean">
    <property name="entryIndicator">
    <value>Y</value>
    </property>
    </bean>

    Although, when loading this context file into the ApplicationContext, I am receiving the exception:

    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Character] for property 'entryIndicator'

    Any ideas how I can explicitly define 'entryIndicator' as a java.lang.Character rather than a String?

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    As far as I am aware there is no PropertyEditor in Spring for doing this nor is there default suppotrt by JavaBeans. You can create your own PropertyEditor and then register it with CustomEditorConfigurer.

    Check the JavaDocs for CustomEditorConfigurer and have a look at the code for some of the PropertyEditor supplied with Spring.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

Posting Permissions

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