Announcement Announcement Module
Collapse
No announcement yet.
Converting LinkedList to String[] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting LinkedList to String[]

    I'm trying to create a list to feed into the setBasenames of ResourceBundleMessageSource. I've done this under other 2.0.x versions of Spring, but now that I've upgraded to 2.0.6, I get the following error:

    Code:
    922  ERROR org.springframework.web.context.ContextLoader | Context initializatio
    n failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean wit
    h name 'messageSource' defined in ServletContext resource [/WEB-INF/conf/spring/
    beans.xml]: Error setting property values; nested exception is org.springframewo
    rk.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Fail
    ed to convert property value of type [java.util.LinkedList] to required type [ja
    va.lang.String[]] for property 'basenames'; nested exception is java.lang.Illega
    lArgumentException: Cannot convert value of type [java.util.ArrayList] to requir
    ed type [java.lang.String] for property 'basenames[0]': no matching editors or c
    onversion strategy found
    Caused by:
    org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExc
    eption details (1) are:
    PropertyAccessException 1:
    org.springframework.beans.TypeMismatchException: Failed to convert property valu
    e of type [java.util.LinkedList] to required type [java.lang.String[]] for prope
    rty 'basenames'; nested exception is java.lang.IllegalArgumentException: Cannot
    convert value of type [java.util.ArrayList] to required type [java.lang.String]
    for property 'basenames[0]': no matching editors or conversion strategy found
    Caused by:
    java.lang.IllegalArgumentException: Cannot convert value of type [java.util.Arra
    yList] to required type [java.lang.String] for property 'basenames[0]': no match
    ing editors or conversion strategy found
            at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(Ty
    peConverterDelegate.java:231)
    here's my code:

    Code:
    	<util:list id="msgBasenames" list-class="java.util.LinkedList">
    	  <list>
    		<value>messages</value>
    		<value>questions</value>
    	  </list>
        </util:list>	
    
    	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    		<property name="basenames" ref="msgBasenames">
    		</property>
    	</bean>
    Not sure what to do here.

    Thanks.

  • #2
    I started diagnosing the differences between this and the other instance that did the same thing. I had util and bean namespaces in opposite order, so I switched them and th eproblem went away.

    Whatever!

    Comment


    • #3
      So you switched the XML schema definition at the top of the file and it solved it? Interesting.......... .
      Last edited by karldmoore; Aug 27th, 2007, 03:31 PM.

      Comment

      Working...
      X