openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-261) UnsupportedOperationException occurred in BrokerImpl.java
Date Wed, 20 Jun 2007 05:40:26 GMT

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

Patrick Linskey commented on OPENJPA-261:
-----------------------------------------

Update from Teresa's email:

Sorry it was not NPE, it was UnsupportedOperationException. I had the NPE
before and somehow mixed up with two. Anyway, it caused by :
java.lang.UnsupportedOperationException: IteratorChains must contain at
least one Iterator

The Collecitons.EMPTY_LIST.iterator() does not return null.
Here is the exception stack:

4781 emptest TRACE [main] openjpa.Runtime - An exception occurred while
ending the transaction. This exception will be re-thrown.

<0.0.0 nonfatal user error> org.apache.openjpa.util.NoTransactionException:
Can only perform operation while a transaction is active.

at org.apache.openjpa.kernel.BrokerImpl.assertActiveTransaction(
BrokerImpl.java:4307)

at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java
:1806)

at org.apache.openjpa.kernel.LocalManagedRuntime.rollback(
LocalManagedRuntime.java:123)

at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
LocalManagedRuntime.java:104)

at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1319)

at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java
:869)

at org.apache.openjpa.persistence.EntityManagerImpl.commit(
EntityManagerImpl.java:409)

at tutorial.ejb.TestEmpsPerClass.main(TestEmpsPerClass.java:135)

4781 emptest TRACE [main] openjpa.Runtime - An exception occurred while
ending the transaction. This exception will be re-thrown.

<0.0.0 nonfatal store error> org.apache.openjpa.util.StoreException:
IteratorChains must contain at least one Iterator

at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java
:1833)

at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
LocalManagedRuntime.java:93)

at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1319)

at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java
:869)

at org.apache.openjpa.persistence.EntityManagerImpl.commit(
EntityManagerImpl.java:409)

at tutorial.ejb.TestEmpsPerClass.main(TestEmpsPerClass.java:135)

Caused by: java.lang.UnsupportedOperationException: IteratorChains must
contain at least one Iterator

at
org.apache.commons.collections.iterators.IteratorChain.checkChainIntegrity(Unknown
Source)

at org.apache.commons.collections.iterators.IteratorChain.lockChain(Unknown
Source)

at org.apache.commons.collections.iterators.IteratorChain.hasNext(Unknown
Source)

at org.apache.openjpa.kernel.BrokerImpl.endTransaction(BrokerImpl.java:2196)

at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java
:1809)

... 5 more

<0.0.0 fatal store error> org.apache.openjpa.persistence.RollbackException:
IteratorChains must contain at least one Iterator

at org.apache.openjpa.persistence.EntityManagerImpl.commit(
EntityManagerImpl.java:420)

at tutorial.ejb.TestEmpsPerClass.main(TestEmpsPerClass.java:135)

Caused by: <0.0.0 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: IteratorChains must
contain at least one Iterator

at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java
:1833)

at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
LocalManagedRuntime.java:93)

at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1319)

at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java
:869)

at org.apache.openjpa.persistence.EntityManagerImpl.commit(
EntityManagerImpl.java:409)

... 1 more

Caused by: java.lang.UnsupportedOperationException: IteratorChains must
contain at least one Iterator

at
org.apache.commons.collections.iterators.IteratorChain.checkChainIntegrity(Unknown
Source)

at org.apache.commons.collections.iterators.IteratorChain.lockChain(Unknown
Source)

at org.apache.commons.collections.iterators.IteratorChain.hasNext(Unknown
Source)update different fields

at org.apache.openjpa.kernel.BrokerImpl.endTransaction(BrokerImpl.java:2196)

at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java
:1809)

... 5 more


> UnsupportedOperationException occurred in BrokerImpl.java
> ---------------------------------------------------------
>
>                 Key: OPENJPA-261
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-261
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 0.9.7
>         Environment: Window XP
>            Reporter: Teresa Kan
>            Priority: Critical
>         Attachments: NPE.patch
>
>
> While I was testing against the openjpa code, I got an UnsupportedOperationException
in the BrokerImpl.endtransaction() method. The method set the transState to an empty Collection
if there is no cache for transactions. Later the code got an UnsupportedOperationException.
> Original code:
> Collection transStates = _transCache;
>         if (transStates == null)
>             transStates = Collections.EMPTY_LIST;
> .....
> for (Iterator itr = transStates.iterator(); itr.hasNext();) {
>             sm = (StateManagerImpl) itr.next();
>             try {
>                 if (rollback) {
>                     // tell objects that may have been derefed then flushed
>                     // (and therefore deleted) to un-deref
>                     sm.setDereferencedDependent(false, false);
>                     sm.rollback();
>                 } else
>                     sm.commit();
>             } catch (RuntimeException re) {
>                 exceps = add(exceps, re);
>             }
>          }
> I put a check before this "for" loop then the UnsupportedOperationException
> disappeared.
> if (!transStates.isEmpty()) {   
>         	for (Iterator itr = transStates.iterator(); itr.hasNext();) {
>             sm = (StateManagerImpl) itr.next();
>             try {
>                 if (rollback) {
>                     // tell objects that may have been derefed then flushed
>                     // (and therefore deleted) to un-deref
>                     sm.setDereferencedDependent(false, false);
>                     sm.rollback();
>                 } else
>                     sm.commit();
>             } catch (RuntimeException re) {
>                 exceps = add(exceps, re);
>             }
>          }
>         }
> The NPE.patch is attached to this JIRA. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message