Связывание Spring Webflow: Converter - java.lang.IllegalArgumentException: каждый объект конвертера должен реализовывать один из интерфейсов Converter…

У меня есть следующий код в одном конфигурационных файлов XML Spring:

  

  
    
        
            
                            
            
        
    
  

Но я получаю следующее исключение во время развертывания (на JBoss):

java.lang.IllegalArgumentException: каждый объект конвертера должен реализовать один из Converter, ConverterFactory или GenericConverter интерфейсы

Есть идеи, почему? Насколько я понимаю, org.springframework.binding.convert.converters.StringToDate является реализацией Converter .

ОБНОВЛЕНИЕ:

Только что нашел этот ответ, который предполагает, что смешивание Converter и PropertyEditor может вызвать проблемы. У меня есть часть в моем приложении, использующая PropertyEditor s, но, насколько я могу судить, в документации не говорится о каких-либо проблемах со смешиванием двух систем.

Трассировка стека:

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

ОБНОВЛЕНИЕ 2:

Я изменил свой xml на:

  

  
    
        
            
                
                
            
        
    
  

Мой собственный конвертер:

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 {

    public Date convert(String source) {

        Date date = null;

        try {
            date = (Date) convertSourceToTargetClass(getPattern(), getTargetClass());
        } catch (Exception e) {

        }

        return date;
    }

}

ОДНАКО, читая следующую ветку форума , я ожидал, что преобразование в работу. Если я понял их правильно, они говорят, что после правильной настройки конвертера он должен работать с Spring Batch, то есть не требует каких-либо специальных настроек, чтобы он работал конкретно с Spring Batch. Но я все еще получаю исключение BindException во время пакетной задачи ... есть идеи, почему?

См. Новую трассировку стека:

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

См. Также мой исходный вопрос (все еще нерешенный).

5
задан Community 23 May 2017 в 10:24
поделиться