Spring package using java annotations java.lang.IllegalStateException: cannot create properties without metadata

  • Attempts to automate FieldSets for domain objects using java anotations only in the project
  • Failed to complete the following:

    BeanWrapperFieldSetMapper.mapFieldSet (line 184) in the 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 try to use Automap.

  • Below 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;
        }
    
  • 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,dahiya.naveen@gmail.com,m]

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

+4
source share
1 answer

You miss likeTokenizer.setNames () because you work with names (the names of your properties Partner)

+1
source

All Articles