title: java.lang.ClassCastException: java.util.Vector cannot be cast to java.util.ArrayList
body: <p>I'm learning JavaEE, and looking for some help. I'm trying to get all record from a Derby DB table to display on a xhtml page (dataTable). I received this error "java.lang.ClassCastException: java.util.Vector cannot be cast to java.util.ArrayList".</p>
  
  <ol>
  <li>Can someone explain the error and how I need to fix it?</li>
  <li>How do I trigger the data table to be shown only when the "Print" button is clicked?
  Thanks in advance</li>
  </ol>
  
  <p>My named query:</p>
  
  <blockquote>
    <p>NamedQueries({
        @NamedQuery(name="getAllItemActivities", query="select c from LibraryItemActivity c")
    })</p>
  </blockquote>
  
  <p>My bean manager:</p>
  
  <blockquote>
    <p>private ArrayList activities;</p>
    
    <p>public ArrayList getActivities() {</p>
  
  <pre><code>  return control.getActivites();
  </code></pre>
    
    <p>}</p>
  </blockquote>
  
  <p>My control bean:</p>
  
  <blockquote>
    <p>public ArrayList getActivites() { </p>
  
  <pre><code>  ArrayList&lt;LibraryItemActivity&gt; temp = (ArrayList&lt;LibraryItemActivity&gt;) em.createNamedQuery("getAllItemActivities").getResultList();
  
    return temp;
  </code></pre>
    
    <p>}   </p>
  </blockquote>
  
  <p>My html data table:</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;h:commandButton value = "Print"&gt;&lt;/h:commandButton&gt;
      &lt;h:dataTable value = "#{libraryBeanManager.activities}" var = "a"&gt;
          &lt;h:column&gt;
              &lt;f:facet name="header"&gt;Book Title:&lt;/f:facet&gt;
              #{a.libraryitemtitle}
          &lt;/h:column&gt;
          &lt;h:column&gt;
              &lt;f:facet name="header"&gt;Author:&lt;/f:facet&gt;
              #{a.patron}
          &lt;/h:column&gt;
          &lt;h:column&gt;
              &lt;f:facet name="header"&gt;Publisher:&lt;/f:facet&gt;
              #{a.activitytype}
          &lt;/h:column&gt;
      &lt;/h:dataTable&gt;  
  &lt;/h:form&gt;
  </code></pre>