Invalid field while parsing

712 views
Skip to first unread message

Rajesh Venkatachalapathy

unread,
Oct 14, 2013, 5:35:47 PM10/14/13
to bea...@googlegroups.com
Hi Kevin,

I am trying to use your package. I am getting the following error:

Exception in thread "main" org.beanio.BeanIOConfigurationException: Invalid field 'firstName', in record 'employee', in stream 'employeeFile': No such property 'firstName' in class 'example.Employee'
    at org.beanio.internal.compiler.ProcessorSupport.process(ProcessorSupport.java:93)
    at org.beanio.internal.compiler.ParserFactorySupport.createStream(ParserFactorySupport.java:95)
    at org.beanio.internal.compiler.StreamCompiler.createStreamDefinitions(StreamCompiler.java:130)
    at org.beanio.internal.compiler.StreamCompiler.loadMapping(StreamCompiler.java:84)
    at org.beanio.internal.DefaultStreamFactory.load(DefaultStreamFactory.java:52)
    at org.beanio.StreamFactory.load(StreamFactory.java:258)
    at org.beanio.StreamFactory.load(StreamFactory.java:234)
    at org.beanio.StreamFactory.load(StreamFactory.java:223)
    at example.BeanReaderExample.main(BeanReaderExample.java:11)
Caused by: org.beanio.BeanIOConfigurationException: No such property 'firstName' in class 'example.Employee'
    at org.beanio.internal.compiler.ParserFactorySupport.getPropertyDescriptor(ParserFactorySupport.java:1291)
    at org.beanio.internal.compiler.ParserFactorySupport.reflectPropertyType(ParserFactorySupport.java:1222)
    at org.beanio.internal.compiler.ParserFactorySupport.handleField(ParserFactorySupport.java:813)
    at org.beanio.internal.compiler.ProcessorSupport.handleComponent(ProcessorSupport.java:139)
    at org.beanio.internal.compiler.ProcessorSupport.handleComponent(ProcessorSupport.java:125)
    at org.beanio.internal.compiler.ProcessorSupport.handleComponent(ProcessorSupport.java:109)
    at org.beanio.internal.compiler.ProcessorSupport.process(ProcessorSupport.java:46)
    ... 8 more

I tried the simple example from the webpage


<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="employeeFile" format="csv">
    <record name="employee" class="example.Employee">
      <field name="firstName" />
      <field name="lastName" />
      <field name="title" />
      <field name="salary" />
      <field name="hireDate" format="MMddyyyy" />
    </record>
  </stream>
</beanio>

package example;

import org.beanio.*;
import java.io.*;

public class BeanReaderExample {
    public static void main(String[] args) throws Exception {
        // create a StreamFactory
        StreamFactory factory = StreamFactory.newInstance();
        // load the mapping file
        factory.load("src\\example\\mapping.xml");
     
        // use a StreamFactory to create a BeanReader
        BeanReader in = factory.createReader("employeeFile", new File("src\\example\\employee.csv"));
        Employee employee;
        while ((employee = (Employee) in.read()) != null) {
            System.out.println(employee.firstNAME);
        }
        in.close();
    }
}


package example;

import java.util.Date;

public class Employee {
    String firstNAME;
    String lastName;
    String title;
    int salary;
    Date hireDate;
   
    // getters and setters not shown...
}

am i doing something wrong.

Thanks much in advance.

-Rajesh

Rajesh Venkatachalapathy

unread,
Oct 14, 2013, 5:37:32 PM10/14/13
to bea...@googlegroups.com
typo on my earlier post  firstNAME should have read firstName

Thanks,

Kevin

unread,
Oct 16, 2013, 10:16:28 PM10/16/13
to bea...@googlegroups.com
Did you add the getters and setters to the Employee class?

Thanks,
Kevin
Reply all
Reply to author
Forward
0 new messages