From dev-return-6177-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Thu Sep 13 14:06:58 2007 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 608 invoked from network); 13 Sep 2007 14:06:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Sep 2007 14:06:56 -0000 Received: (qmail 55775 invoked by uid 500); 13 Sep 2007 14:06:49 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 55736 invoked by uid 500); 13 Sep 2007 14:06:49 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 55726 invoked by uid 99); 13 Sep 2007 14:06:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Sep 2007 07:06:49 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Sep 2007 14:08:34 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 25B7271413F for ; Thu, 13 Sep 2007 07:06:32 -0700 (PDT) Message-ID: <21181990.1189692392129.JavaMail.jira@brutus> Date: Thu, 13 Sep 2007 07:06:32 -0700 (PDT) From: "Vikram Bhatia (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-368) Multithreaded client fails randomly on EntityManager.persist() with out transaction context. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Multithreaded client fails randomly on EntityManager.persist() with out transaction context. -------------------------------------------------------------------------------------------- Key: OPENJPA-368 URL: https://issues.apache.org/jira/browse/OPENJPA-368 Project: OpenJPA Issue Type: Bug Components: jdbc Affects Versions: 1.0.0, 0.9.7 Environment: WebLogic Server 10.0, Oracle DB Reporter: Vikram Bhatia This issue happens with the following scenario with JTA transaction. Suppose there is Entity A which is related to table with two columns accountId and name. accountId is PK of the table whose value is generated using sequence in DB. 1. Thread A starts Transaction 1. 2. Thread B starts Transaction 2. 3. Thread A and Thread B both calls EntityManager.persist(o) where o is Entity object whose primary key is generated with a sequence in DB. 4. A call is made to o.getAccountId() concurrently. 5. Thread A suspends Transaction 1, and gets the value of accountId. It updates sequence value in DB with new Transaction 3. It saves Transaction 1. 6. Thread B suspends Transaction 2, and gets the value of accountId. It updates sequence value in DB with new Transaction 4. It saves Transaction 2. 7. Now, when both Thread A and Thread B resumes outer transaction concurrently, it updates Transaction Manager with Transaction 2. The problem happens when JTA transaction is saved in AbstractJDBCSeq _outerTransaction variable. The variable gets overwritten if multiple threads load the value of accountId from sequence in DB, when it resumes the JTA transaction later it resumes the transaction 2 for both threads resulting in following exception. javax.ejb.EJBException: nested exception is: javax.persistence.TransactionRequiredException: The method public abstract void javax.persistence.EntityManager.persist(java.lang.Object) must be called in the context of a transaction. javax.persistence.TransactionRequiredException: The method public abstract void javax.persistence.EntityManager.persist(java.lang.Object) must be called in the context of a transaction. at weblogic.deployment.BasePersistenceContextProxyImpl.validateInvocation(BasePersistenceContextProxyImpl.java:121) at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:86) at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:90) at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80) at $Proxy63.persist(Unknown Source) Please check README.txt of attached testcase.zip to see how to reproduce the issue. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.