title: Vaadin issue with adding items from a List to vaadin Table
body: <p>I'm new to vaadin, I'm trying to implement EclipseLink with vaadin, in my project i'm trying to get list of states from db using eclipselink and i'm getting the result set in my main file but when trying to add this items into a table using for each loop i'm getting a strange error </p>
  
  <blockquote>
    <p>com.vaadin.server.ServiceException: java.lang.ClassCastException: com.example.dao.States cannot be cast to com.example.dao.States.</p>
  </blockquote>
  
  <h2>PFB code snippets</h2>
  
  <h3>Main Java File:</h3>
  
  <pre><code>@WebServlet(value = "/*", asyncSupported = true)
  @VaadinServletConfiguration(productionMode = false, ui = VaadintestUI.class)
  public static class Servlet extends VaadinServlet {
  }
  @Override
  protected void init(VaadinRequest request) {
  
      final String PERSISTENCE_UNIT_NAME = "com.test.jpa";
  
      EntityManagerFactory factory;
      final VerticalLayout layout = new VerticalLayout();
      layout.setMargin(true);
      factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
      EntityManager em = factory.createEntityManager();
      Query q = em.createQuery("select s from States s");
      List&lt;States&gt; stateList = q.getResultList();
      System.out.println("Size: " + stateList.size());
      Table table = new Table("The US States");
      table.addContainerProperty("Name", String.class, null);
  
      table.addContainerProperty("Population", Integer.class, null);
  
      for (int i = 0; i &lt; stateList.size(); i++) 
      {           
      table.addItem(new Object[]{ stateList.get(i).getState(),stateList.get(i).getPopulation()},i);
      }
      table.setPageLength(table.size());
      layout.addComponent(table);
  }
  
  }
  </code></pre>
  
  <h3>Persitence.xml</h3>
  
  <pre><code>  &lt;persistence-unit name="com.test.jpa" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;class&gt;com.example.dao.States&lt;/class&gt;
      &lt;properties&gt;
        &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /&gt;
        &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/testdb" /&gt;
        &lt;property name="javax.persistence.jdbc.user" value="root" /&gt;
        &lt;property name="javax.persistence.jdbc.password" value="root" /&gt;
      &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  </code></pre>
  
  <h3>States.java</h3>
  
  <pre><code>@Entity
  public class States {
  
      @Id
      private Long id;
      private String state;
      private String population;
      //Setters and getters//
  </code></pre>
  
  <p>Stack trace                                                                                         Caused By: java.lang.ClassCastException: com.example.dao.States cannot be cast to           com.example.dao.States
         at com.example.vaadintest.VaadintestUI.init(VaadintestUI.java:69)
         at com.vaadin.ui.UI.doInit(UI.java:645)
        at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:222)
        at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
        at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)</p>