title: ClassCastException from exact same class
body: <p>I'm running a database query and trying to cast the result to a Customer object, but I'm getting an error saying:</p>
  
  <pre><code>java.lang.ClassCastException: Entities.Customer cannot be cast to Entities.Customer
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>Customer c = (Customer)em.createNamedQuery("Customer.findByEmail")
          .setParameter("email", user)
          .getSingleResult();
  </code></pre>
  
  <p>I've read that this is due to classloaders, but to be honest it's a bit over my head. Is there a huge issue somewhere else, or am I just casting it incorrectly?</p>