openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Chauvet (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (OPENJPA-2360) ClassCastException: DetachedValueStateManager cannot be cast to StateManagerImpl
Date Tue, 02 Apr 2013 15:17:14 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-2360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13619902#comment-13619902
] 

Guillaume Chauvet edited comment on OPENJPA-2360 at 4/2/13 3:17 PM:
--------------------------------------------------------------------

I'm not be able to create the expected unitary test... However we obtain now a OptimisticLockException
stacktrace instead of ClassCastException (after applying the patch):
======================
Caused by: <openjpa-2.2.2-QFD-r422266:1446687M nonfatal store error> org.apache.openjpa.persistence.OptimisticLockException:
An optimistic lock violation was detected when flushing object instance [...]
	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:124)
	at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:79)
	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:100)
	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:88)
	at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)
	at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:107)
	at org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:105)
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:78)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:732)
	at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
	... 46 more

Caused by this loop :
============================
for (AbstractAdminNode<?> node : root.getChildren()) {
            if (node instanceof CenterNode) {
                CenterNode centerNode = (CenterNode) node;
                CenterDAO.getInstance().persist(centerNode.getData()); // <- exception
            }
        }


Workaround : the code below solves the raised exception.
============================

        Set<Center> centers = new HashSet<Center>();
        for (AbstractAdminNode<?> node : root.getChildren()) {
            if (node instanceof CenterNode) {
                CenterNode centerNode = (CenterNode) node;
                centers.add(centerNode.getData());
            }
        }
        CenterDAO.getInstance().persist(centers.toArray(new Center[0])); // call em.persistAll(E...)
                
      was (Author: gchauvet):
    I'm not be able to create the expected unitary test... However we obtain now a OptimisticLockException
stacktrace instead of ClassCastException :
======================
Caused by: <openjpa-2.2.2-QFD-r422266:1446687M nonfatal store error> org.apache.openjpa.persistence.OptimisticLockException:
An optimistic lock violation was detected when flushing object instance [...]
	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:124)
	at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:79)
	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:100)
	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:88)
	at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)
	at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:107)
	at org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:105)
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:78)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:732)
	at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
	... 46 more

Caused by this loop :
============================
for (AbstractAdminNode<?> node : root.getChildren()) {
            if (node instanceof CenterNode) {
                CenterNode centerNode = (CenterNode) node;
                CenterDAO.getInstance().persist(centerNode.getData()); // <- exception
            }
        }


Workaround : the code below solves the raised exception.
============================

        Set<Center> centers = new HashSet<Center>();
        for (AbstractAdminNode<?> node : root.getChildren()) {
            if (node instanceof CenterNode) {
                CenterNode centerNode = (CenterNode) node;
                centers.add(centerNode.getData());
            }
        }
        CenterDAO.getInstance().persist(centers.toArray(new Center[0])); // call em.persistAll(E...)
                  
> ClassCastException: DetachedValueStateManager cannot be cast to StateManagerImpl
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2360
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2360
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 2.2.1
>            Reporter: Guillaume Chauvet
>            Priority: Blocker
>         Attachments: OPENJPA-2360.patch
>
>
> The corresponding stacktrace :
> ==========================================
> Caused by: <openjpa-2.2.2-QFD-r422266:1446687M nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
org.apache.openjpa.kernel.DetachedValueStateManager cannot be cast to org.apache.openjpa.kernel.StateManagerImpl
> 	at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:2002)
> 	at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
> 	at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1518)
> 	at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:933)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:570)
> 	... 39 more
> Caused by: java.lang.ClassCastException: org.apache.openjpa.kernel.DetachedValueStateManager
cannot be cast to org.apache.openjpa.kernel.StateManagerImpl
> 	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:134)
> 	at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:79)
> 	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:100)
> 	at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:88)
> 	at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)
> 	at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:107)
> 	at org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
> 	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:105)
> 	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:78)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:732)
> 	at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
> 	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2178)
> 	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2076)
> 	at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1994)
> 	... 43 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message