openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Catalina Wei (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (OPENJPA-398) ConcurrentModificationException at org.apache.openjpa.kernel.BrokerImpl
Date Thu, 19 Aug 2010 23:03:16 GMT

     [ https://issues.apache.org/jira/browse/OPENJPA-398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Catalina Wei resolved OPENJPA-398.
----------------------------------

         Assignee: Catalina Wei
    Fix Version/s: 2.1.0
       Resolution: Duplicate

Duplicate of OPENJPA-641, and the problem is not reproducible.

Correction to testcase:

Query q = em.createQuery("SELECT a FROM A a WHERE a.name=:cName")
                                .setParameter(1, cName);
should be:

Query q = em.createQuery("SELECT a FROM A a WHERE a.name=:cName")
            .setParameter("cName", cName);


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.    
 */
package org.apache.openjpa.persistence.kernel;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import org.apache.openjpa.persistence.kernel.common.apps.A;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

public class TestA641 extends SingleEMFTestCase {

    private int cId;
    private String cName = null;
    public void setUp() throws Exception {
        super.setUp(CLEAR_TABLES, A.class);
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        // a
        A a = new A("a");
        em.persist(a);
        // b
        A b = new A("b");
        b.setParent(a);
        em.persist(b);
        // c
        A c = new A("c");
        c.setParent(b);
        em.persist(c);
        em.getTransaction().commit();
        cId = c.getId();
        cName = c.getName();
        em.close();
    }

    public void testOpenjpa641() {
        EntityManager em = emf.createEntityManager();

        //both methods of getting entity results in same error
        A c = em.find(A.class, cId);
        em.clear();

        Query q = em.createQuery("SELECT a FROM A a WHERE a.name=:cName")
            .setParameter("cName", cName);

        A newC = (A)q.getSingleResult();
        assertEquals(c.getName(), newC.getName());
        em.close();
    }
}

> ConcurrentModificationException at org.apache.openjpa.kernel.BrokerImpl
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-398
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-398
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.2.0
>         Environment: JDK Sun 1.6.0.06 on Ubuntu
>            Reporter: Alexander
>            Assignee: Catalina Wei
>            Priority: Critical
>             Fix For: 2.1.0
>
>
> Hello.
>  
> I'm trying to use OpenJPA in my project. I use Liferay based on Toncat as front-end.
> I use OpenJPA 1.0.0
> Today I have got strange exception - 
> 10:35:55,785 ERROR ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
 at java.util.HashMap$KeyIterator.next(HashMap.java:823) at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.dirtyCheck(BrokerImpl.java:4612)
>         at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.access$000(BrokerImpl.java:4352)
at org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3731)
>         at org.apache.openjpa.kernel.BrokerImpl.setDirty(BrokerImpl.java:3848) at org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:207)
>         at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1532)
at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1471)
>         at org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.java:808)
at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.dirtyCheck(BrokerImpl.java:4612)
>         at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.access$000(BrokerImpl.java:4352)
at org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3731)
>         at org.apache.openjpa.kernel.BrokerImpl.setDirty(BrokerImpl.java:3848) at org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:207)
>         at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1532)
at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1471)
>         at org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.java:808)
at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.dirtyCheck(BrokerImpl.java:4612)
>         at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.access$000(BrokerImpl.java:4352)
>  
> It happens only, when I deploy application on portal, and only when service is first-time
accessed.
> All tests work fine.
>  
> Exception throws in get method
> Transactions are managed by Spring and i use Spring agent.

-- 
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