what's wrong with the BeanItemContainer?

HERE ARE MY CODES:

package com.example.tabledemo1;

import java.io.Serializable;

import com.vaadin.Application;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.ui.*;

public class Tabledemo1Application extends Application {
@Override
public void init() {
Window mainWindow = new Window(“Tabledemo1 Application”);
BeanItemContainer container=new BeanItemContainer(Person.class);
container.addBean(new Person(“zhang “,25,“LONDON”));
container.addBean(new Person(“li”,23,“PARIS”));
Table table=new Table(””,container);
table.setVisibleColumns(new Object{“name”,“age”,“city”});
table.setColumnHeaders(new String{“Name”,“Age”,“City”});
mainWindow.addComponent(table);
setMainWindow(mainWindow);
}

}

class Person implements Serializable{
String name;
int age;
String city;

public Person()
{
	
}
public Person(String name,int age,String city)
{
	this.name=name;
	this.age=age;
	this.city=city;
}

public String getName()
{
	return name;
}
public int getAge()
{
	return age;
	
}
public String getCity()
{
	return city;
}

public void setName(String name)
{
	this.name=name;
}
public void setAge(int age)
{
	this.age=age;
}
public void setCity(String city)
{
	this.city=city;
}

}

It does not work with the error:http 500 status
exception

javax.servlet.ServletException
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:972)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:529)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

com.vaadin.data.util.MethodProperty$MethodException
com.vaadin.data.util.MethodProperty.getValue(MethodProperty.java:630)
com.vaadin.data.util.MethodProperty.toString(MethodProperty.java:643)
com.vaadin.ui.Table.formatPropertyValue(Table.java:2702)
com.vaadin.ui.Table.getPropertyValue(Table.java:2681)
com.vaadin.ui.Table.refreshRenderedCells(Table.java:1560)
com.vaadin.ui.Table.attach(Table.java:2797)
com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
com.vaadin.ui.Panel.attach(Panel.java:491)
com.vaadin.ui.Window.setApplication(Window.java:913)
com.vaadin.Application.addWindow(Application.java:356)
com.vaadin.Application.setMainWindow(Application.java:668)
com.example.tabledemo1.Tabledemo1Application.init(Tabledemo1Application.java:20)
com.vaadin.Application.start(Application.java:549)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1152)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:465)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

BY THE WAY:how can i set my itemid with beanitemcontainer,for example:I want the name to be my itemid of the row,how can i do it?

Best Regards!

Based on a quick look, I don’t see anything obviously wrong here, but for some reason one of the getter methods in Person does not seem to be found. You could put an exception breakpoint on MethodException and see what is the getter it is trying to call, and why that fails.

As the javadoc for BeanItemContainer indicates, “BeanItemContainer uses the beans themselves as identifiers.”
To use other identifiers, you need to use some other container.

Try out the CollectionContainer add-on:
http://vaadin.com/addon/collectioncontainer

Then this should do the job:

Container myContainer = CollectionContainer.fromBeans(myCollectionOfBeans, true);

(more sample scenarios here:
sami.virtuallypreinstalled.com/collectioncontainer/
)

Try by making Person public accessible: “public class Person”.

The itemId of the BeanItemContainer is the bean itself. If that is not what you are looking for, perhaps you should look for a different data source implementation.