title: Spring Webflow binding: Converter - java.lang.IllegalArgumentException: Each converter object must implement one of the Converter ... interfaces
body: <p>I have the following code in one of the Spring's XML config files:</p>
  
  <pre><code>  &lt;mvc:annotation-driven conversion-service="conversionService" /&gt;
  
    &lt;bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"&gt;
      &lt;property name="converters"&gt;
          &lt;list&gt;
              &lt;bean class="org.springframework.binding.convert.converters.StringToDate"&gt;
                  &lt;property name="pattern" value="yyyy-MM-dd" /&gt;            
              &lt;/bean&gt;
          &lt;/list&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  </code></pre>
  
  <p>But I am getting the following exception <strong>during deployment</strong> (on JBoss):</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Each converter object must
    implement one of the Converter, ConverterFactory, or GenericConverter
    interfaces</p>
  </blockquote>
  
  <p><strong>Any idea why?</strong> As far as I can see, <a href="http://static.springsource.org/spring-webflow/docs/2.0.x/javadoc-api/org/springframework/binding/convert/converters/StringToDate.html" rel="nofollow noreferrer">org.springframework.binding.convert.converters.StringToDate</a> is an implementation of <code>Converter</code>.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Just found <a href="https://stackoverflow.com/questions/5982984/why-isnt-spring-using-my-converterstring-date">this</a> answer, that suggests that mixing <code>Converter</code>s and <code>PropertyEditor</code>s might cause problems. I do have part in my app that use <code>PropertyEditor</code>s, but as far as I can see, the documentation does not talk about any problem with mixing the two systems.</p>
  
  <p><strong>Stack trace:</strong></p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Each converter object must implement one of the Converter, ConverterFactory, or GenericConverter interfaces
      at org.springframework.core.convert.support.ConversionServiceFactory.registerConverters(ConversionServiceFactory.java:106)
      at org.springframework.context.support.ConversionServiceFactoryBean.afterPropertiesSet(ConversionServiceFactoryBean.java:56)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
      ... 146 more
  </code></pre>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>I changed my xml to be:</p>
  
  <pre><code>  &lt;mvc:annotation-driven conversion-service="conversionService" /&gt;
  
    &lt;bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"&gt;
      &lt;property name="converters"&gt;
          &lt;set&gt;
              &lt;bean class="my.project.StringToDate"&gt;
                  &lt;!-- org.springframework.binding.convert.converters.StringToDate DEFAULT_PATTERN = "yyyy-MM-dd" --&gt;
                  &lt;property name="pattern" value="yyyy-MM-dd" /&gt;
              &lt;/bean&gt;
          &lt;/set&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  </code></pre>
  
  <p>My custom converter is:</p>
  
  <pre><code>package my.project;
  
  import java.util.Date;
  
  import org.springframework.core.convert.converter.Converter;
  
  public class StringToDate extends org.springframework.binding.convert.converters.StringToDate implements Converter&lt;String, Date&gt; {
  
      public Date convert(String source) {
  
          Date date = null;
  
          try {
              date = (Date) convertSourceToTargetClass(getPattern(), getTargetClass());
          } catch (Exception e) {
  
          }
  
          return date;
      }
  
  }
  </code></pre>
  
  <p>HOWEVER, reading <a href="http://forum.springsource.org/showthread.php?108480-Register-TypeConverter-PropertyEditor-w-Spring-Batch&amp;s=d25d2109922684ad97fbd5fcd3b84cef&amp;p=359747#post359747" rel="nofollow noreferrer">the following forum thread</a> I would expect the conversion to work. If I get them right, they are saying that once the converter is set correctly, it should be working with Spring Batch, i.e. it does not require any special setting to make it work specifically with Spring Batch. But I am still getting a BindException during the batch task... any idea why?</p>
  
  <p>See the new stack trace:</p>
  
  <pre><code>Caused by: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 2 errors
  Field error in object 'target' on field 'datetimeInactive': rejected value [2011-04-27]; codes [typeMismatch.target.datetimeInactive,typeMismatch.datetimeInactive,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [target.datetimeInactive,datetimeInactive]; arguments []; default message [datetimeInactive]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'datetimeInactive'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'datetimeInactive': no matching editors or conversion strategy found]
  Field error in object 'target' on field 'datetimeActive': rejected value [2011-04-27]; codes [typeMismatch.target.datetimeActive,typeMismatch.datetimeActive,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [target.datetimeActive,datetimeActive]; arguments []; default message [datetimeActive]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'datetimeActive'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'datetimeActive': no matching editors or conversion strategy found]
      at org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper.mapFieldSet(BeanWrapperFieldSetMapper.java:186)
      at org.springframework.batch.item.file.mapping.DefaultLineMapper.mapLine(DefaultLineMapper.java:42)
      at org.springframework.batch.item.file.FlatFileItemReader.doRead(FlatFileItemReader.java:179)
      ... 45 more
  </code></pre>
  
  <p>See also my <a href="https://stackoverflow.com/questions/9059481/spring-batch-how-to-convert-string-from-file-to-date">original question</a> (still unsolved).</p>