Results 1 to 2 of 2

Thread: Newbie Q: Error in setting dependencies

  1. #1
    Join Date
    Dec 2008
    Posts
    13

    Default Newbie Q: Error in setting dependencies

    I have following code :

    <bean name="/add" class="com.hestia.controllers.AddPropertyControlle r" parent="baseController">
    <property name="commandName" value="property"/>
    <property name="commandClass" value="com.hestia.property.UploadBean"/>
    <property name="formView"><value>add-property</value></property>
    <property name="successView"><value>hello</value></property></bean>

    this works fine.. but UploadBean has fields like address which I was trying to inject through dependecy injection rather than writing in constructor..

    so I wrote another bean like this :
    <bean id="uploadBean" value="com.hestia.property.UploadBean">
    <property name="address" value="com.hestia.property.address" />
    </bean>

    and changed the original definition as :
    <bean name="/add" class="com.hestia.controllers.AddPropertyControlle r" parent="baseController">
    <property name="commandName" value="property"/>
    <property name="commandClass" ref="uploadBean"/>
    <property name="formView"><value>add-property</value></property>
    <property name="successView"><value>hello</value></property></bean>

    but this throws following error :
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.hestia.command.beans.PropertyUploadBean] to required type [java.lang.Class] for property 'commandClass'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found

    I guess this accepts a class here..instead of a bean.. so how do I pass dependencies in this case ?

  2. #2

    Default

    Hi,

    Add another bean in your applicationContext.xml :-

    Code:
       <bean id="address" class="com.hestia.property.Address"/>
    Modify your UploadBean definition in this manner :-

    Code:
       <bean id="uploadBean" class="com.hestia.property.UploadBean">
          <property name="address" ref="address"/>
       </bean>
    It'll work now.

    Regards,
    Sandeep

Posting Permissions

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