1

I was trying to use BeanIO to convert CSV to POJO and found an issue that might help some of you some time.

This is the error i got "Invalid field 'LastName', in record 'user', in stream 'userTemplate': No such property 'LastName' in class 'com.mycompany.beanio.User'"

<beanio xmlns="http://www.beanio.org/2012/03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-  instance" xsi:schemaLocation="http://www.beanio.org/2012/03   http://www.beanio.org/2012/03/mapping.xsd">
<stream name="userTemplate" format="csv">

    <record  name="user" class="com.mycompany.beanio.User">    
        <field name="FirstName"/>
        <field name="LastName"/>
        <field name="Email" />
    </record>
</stream>
</beanio>

this is my java class

package com.mycompany.beanio;
import org.apache.commons.lang3.RandomStringUtils;
import java.math.BigDecimal;


/**
*
* @author Yoash izhack yoashos@gmail.com   
*/
class User 
{


private String      FirstName;
private String      LastName;
private String      Email;
Get&Set dwon here

As you can see do have the property in my class and yet i have an exception. I explored it and found that the properties that are written from the java class are being uncapitilized for the first char. That means that there was a comparison between lastName to LastName although i wrote LastName twice. a fix was submitted for this bug.

user2656851
  • 1,643
  • 4
  • 12
  • 15
  • It is encouraged to answer your own question on this site, as you are helping people. Please, add the solution as an answer so people will know instantly that the case is resolved. You will be able to accept it after two days, but I would like to kindly ask you to do that. And thank you for trying to help the other poor guys who have the same problem. – Lajos Arpad Oct 05 '14 at 11:39

1 Answers1

0

to start property names with an uncapitilized letter ist Java standard. So if you change your properties to the standard all will be work perfect.

emmanuel
  • 9,607
  • 10
  • 25
  • 38