Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Urgent: Error setting list from bean defined in XML config.

  1. #1
    Join Date
    Sep 2004
    Posts
    25

    Default Urgent: Error setting list from bean defined in XML config.

    Hi

    I have a very urgent need to get the follwing bug fixed. Can you please help with the following?

    I have an XML config file which I pull in my application context, the

    XML bean entry is given below for reference. I have a java class
    TestConfig which sets the lists and gets the lists as defined in te config. file. As always the framework should go away and set the list for as per
    the definitions in the XML config file. Unfortunately spring has been unable to accept the defintion of the lists I've given. Please advise if my config XML is incorrect or if my class is not doing the setting/getting correctly.

    The entries for the class are given below as well.


    When I run my app I get the error below please help what am I doibg wrong!

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'TestConfig' defined in class path resource [beans-service-test.xml]: Can't resolve reference to bean 'CVB' while setting property 'convBonds[0]'; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'CVB' is defined: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [instrumentDao,oracleDataSource,hibernateSessionFac tory,TestConfig]; Root of BeanFactory hierarchy

    XML File entries
    ------------------

    <bean id="TestConfig" class="com.services.testConfiguration">
    </property>
    <property name="convBonds">
    <list>
    <ref bean="CVB"/>
    <ref bean="CVP"/>
    </list>
    </property>
    <property name="altIds">
    <list>
    <ref bean="MC"/>
    <ref bean="SE"/>
    <ref bean="IS"/>
    <ref bean="RC"/>
    </list>
    </property>
    </bean>
    </beans>


    TestConfig Class
    --------------------


    /** Sets the convBonds
    * @param BigDecimal convBonds
    */
    public final void setconvBonds(final List convlist) {

    convBonds = convlist;

    }


    /** Sets the altIds
    * @param BigDecimal altIds
    */
    public final void setaltIds(final List altlist) {


    altIds = altlist;


    }




    /**
    * List of Bonds.
    */

    private List convBonds;

    /**
    * List of alt ids.
    */

    private List altIds;


    /** convBonds;
    *
    * @return convBonds;;
    */
    public final List convBonds() {
    return convBonds;
    }



    /**
    * altIds
    * @return altIds;
    */
    public final List altIds() {
    return altIds;
    }


  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    aslam,

    Where in your config file did you declare beans CVB, CVP...
    When using <ref bean=""/> you are asking Spring to use a bean, that is already configured in an accessible config file, to set a property of an other bean.

    Omar.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Sep 2004
    Posts
    25

    Default

    Hi Omar ASW,

    The XML code snippet I have provided is what Ihave defined to try and make this work.

    I have no other definitions for CVB, CVP... I thought that this was the correct way of letting Spring know that these are list items.

    CVB, CVP... and the others are only meant to be list items and not beans! can you please correct my XML code sippet and advise.

    Much obliged.

    Aslam

  4. #4
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    I suppose CVB, CVP... are of type String
    Code:
    <bean id="TestConfig" class="com.services.testConfiguration"> 
      <property name="convBonds"> 
        <list> 
          <value>CVB</value> 
          <value>CVP</value> 
        </list> 
      </property> 
      <property name="altIds"> 
        <list> 
          <value>MC</value>
          <value>SE</value>
          <value>IS</value>
          <value>RC</value>
        </list> 
      </property> 
    </bean>
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  5. #5
    Join Date
    Sep 2004
    Posts
    25

    Default

    Hi

    Thanks for that, but unfortunately, Spring does not like the mutiple
    value enteries . I appreciate that we are saying <list>, but Spring is not accepting muti values in the list.

    However, with just one value Spring is accepting the list , but with mutiple values it is coming up with a multi value entry error.


  6. #6
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    aslam,
    could you post the error log? b/w, what Spring version are you using?
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  7. #7
    Join Date
    Sep 2004
    Posts
    25

    Default

    Omar,

    Unfortunately, I've come home after a long hard day and will be returning tommorrow (Saturday) as Ihave to get this done!. So regrettably, I do not have the output available for the attempt with mutiple values as per your suggestion.

    All I am trying to do is have a list of names (bond names) in a list
    which I can iterate through in my java. As the names can change often I was trying to set up a config java class and a XML config file to do the work as per Springs suggestion in "Registering additional custom PropertyEditors" there they only show a property with a single value which is manipulated via set and get in a java class.

    I can get it to work with single value , but I have a list of items as you can see in my code. Can you suggest how your code example may be tweaked to get Spring to accept the data as a java List ? I wil then try it out tommorow

    Many thanks for your help.

  8. #8
    Join Date
    Sep 2004
    Posts
    25

    Default

    Omar

    I think it's going to be something like this ('ve seen stuff on the web)


    <bean id="TestConfig" class="...">
    <property name="convBonds">
    <value>CVB,CVP</value>
    </property>
    </bean>

    Any idea how Spring would expect this to be held (java data type)?

    Many thanks.

  9. #9
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    This should work too, Spring will convert "CVB,CVP" into a java.util.List that contains two items of type java.lang.String
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  10. #10
    Join Date
    Sep 2004
    Posts
    25

    Default

    Omar,

    Thanks, it's just what I need , hoefully it will do the trick, I'll try it out over the weekend and give you some feedback (least I can do for your kind assistence).


    Have a good weekend.


    Regards,

    Aslam
    8)

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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