Note that there are some explanatory texts on larger screens.

plurals
  1. POClassCastException in JPA Entitiy after redeploy (Glassfish 3.1.2)
    primarykey
    data
    text
    <p>I have a strange effect when undeploying and deploying a WebArchive (.war) with Glassfish 3.1.2.</p> <pre><code>$ asadmin undeploy myWebApp; asadmin deploy target/myWebApp.war </code></pre> <p>It deploys normally, but when I fetch an entity bean via the entity manager, it throws an Exception: <code>[#|2012-12-11T15:26:09.772+0100|SEVERE|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=119;_ThreadName=Thread-2;|java.lang.ClassCastException: org.YourEntity cannot be cast to org.YourEntity</code></p> <p>The exception is thrown in the q.getSingleResult() call.</p> <pre><code> @PersistenceContext(unitName = "org.my-PU") private EntityManager em = Persistence.createEntityManagerFactory("org.my-PU").createEntityManager(); ... public YourEntity findYourEntity() throws Exception { TypedQuery&lt;YourEntity&gt; q = em.createQuery("select ye from YourEntity ye", YourEntity.class); return q.getSingleResult(); } </code></pre> <p>I am using the following JPA related dependencies in the project:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt; &lt;artifactId&gt;javax.persistence&lt;/artifactId&gt; &lt;version&gt;2.0.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt; &lt;artifactId&gt;eclipselink&lt;/artifactId&gt; &lt;version&gt;2.0.2&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.oracle&lt;/groupId&gt; &lt;artifactId&gt;ojdbc6&lt;/artifactId&gt; &lt;version&gt;11.1.0.7.0&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>When I restart the glassfish, the exception does not occur any more. I have never seen the problem when undeploying/deploying an .ear with similar settings. Has anybody seen the error and knows how to overcome it? It is not a big problem, but annoying.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload