Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring batch using java annotations java.lang.IllegalStateException: Cannot create properties without meta data

Tags:

spring-batch

  1. Trying to Automapping FieldSets to Domain Objects using java anotations only in project
  2. Failing at the following :

    BeanWrapperFieldSetMapper.mapFieldSet (line 184) at following line (line 187) :

    binder.bind(new MutablePropertyValues(getBeanProperties(copy, fs.getProperties())));
    @Override
    public Properties getProperties() {
        if (names == null) {
            throw new IllegalStateException("Cannot create properties without meta data");
        }
    

    Note: I did not specify names as I am trying to Automap.

  3. Following is my code :

    @Bean
        public LineMapper<Partner> lineMapper() {
            DefaultLineMapper<Partner> lineMapper = new DefaultLineMapper<Partner>();
            DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
            BeanWrapperFieldSetMapper<Partner> fieldSetMapper = new BeanWrapperFieldSetMapper<Partner>(); 
            fieldSetMapper.setBeanFactory(getApplicationContext()); 
            fieldSetMapper.setTargetType(Partner.class);
            lineMapper.setLineTokenizer(lineTokenizer);
            lineMapper.setFieldSetMapper(fieldSetMapper);
            return lineMapper;
        }
    
  4. Exact stack trace

    Exit-Descr. : org.springframework.batch.item.file.FlatFileParseException: Parsing error at line: 1 in resource=[class path resource [partner-import.csv]], input=[Mustermann,Max,[email protected],m]

    Caused by: java.lang.IllegalStateException: Cannot create properties without meta data at org.springframework.batch.item.file.transform.DefaultFieldSet.getProperties(DefaultFieldSet.java:745)

like image 411
explorer Avatar asked Oct 27 '14 08:10

explorer


1 Answers

You are missing to set likeTokenizer.setNames() because you are working with names (the names of your Partner properties)

like image 193
Luca Basso Ricci Avatar answered Oct 08 '22 06:10

Luca Basso Ricci