Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9F11D188B4 for ; Mon, 29 Jun 2015 10:00:05 +0000 (UTC) Received: (qmail 93092 invoked by uid 500); 29 Jun 2015 10:00:05 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 93053 invoked by uid 500); 29 Jun 2015 10:00:05 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 93041 invoked by uid 99); 29 Jun 2015 10:00:05 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jun 2015 10:00:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 9A81EC09B3 for ; Mon, 29 Jun 2015 10:00:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.001 X-Spam-Level: X-Spam-Status: No, score=0.001 tagged_above=-999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id q-mdkCJ2vPOz for ; Mon, 29 Jun 2015 09:59:58 +0000 (UTC) Received: from zimbra-mta.fenceit.ch (zimbra-mta.fenceit.ch [212.103.90.69]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id CAE37428CC for ; Mon, 29 Jun 2015 09:59:57 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-mta.fenceit.ch (Postfix) with ESMTP id A4A22340C1 for ; Mon, 29 Jun 2015 11:59:49 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra-mta.fenceit.ch Received: from zimbra-mta.fenceit.ch ([127.0.0.1]) by localhost (zimbra-mta.fenceit.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UXRFuleoJrqH for ; Mon, 29 Jun 2015 11:59:49 +0200 (CEST) Received: from b06-zimbra-s.hsz1.oe.ch (vrrp1-s.oe.ch [192.168.10.2]) by zimbra-mta.fenceit.ch (Postfix) with ESMTP id F1A2134085 for ; Mon, 29 Jun 2015 11:59:48 +0200 (CEST) Date: Mon, 29 Jun 2015 11:59:48 +0200 (CEST) From: Antoni =?utf-8?Q?My=C5=82ka?= Reply-To: Antoni =?utf-8?Q?My=C5=82ka?= To: users@openjpa.apache.org Message-ID: <403101971.1222074.1435571988901.JavaMail.root@basis06.ch> In-Reply-To: <2114352189.1219789.1435568834953.JavaMail.root@basis06.ch> Subject: Expected an OptimistickLockException but got a SetRollbackOnlyException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.10.36] X-Mailer: Zimbra 7.2.1_GA_2790 (ZimbraWebClient - GC43 (Win)/7.2.1_GA_2790) Hi, I have an issue whose cause lies somewhere between OpenJPA and Aries. Posti= ng it here first, please redirect me if it's the wrong place. We use Open JPA in Karaf 3.0.2 (detailed bundle versions below). We have an= DAO object, instantiated by Blueprint with a jpa:context and a tx:transact= ion element. It gets the EntityManager from Aries JPA and has a mandatory t= ransaction on each method call. That DAO object has CRUD methods for an entity class that uses optimistic l= ocking. It has a long version field annotated with @Version. Our problem appears when we get the optimistic lock error. We would expect = our MasterDataDao.update method to throw a TransactionRollbackException wit= h an OptimisticLockException as its cause. Instead it throws a TransactionR= ollbackException with a SetRollbackOnlyException as its cause (TransactionI= mpl.java:272). The question is why?=20 I tried debugging the issue. I put a breakpoint at org.apache.geronimo.tran= saction.manager.TransactionImpl.markRollbackCause(java.lang.Throwable) line= : 539. AFAIU the problem is that that method is called *TWICE* when a trans= action is processed. The first time it is called with the "wrong" exception= - SetRollbackOnlyException, the second time it's called with the correct O= ptimisticLockException, but the correct exception isn't recorded in the Tra= nsactionImpl object because the markRollbackCause method looks like this: private void markRollbackCause(Throwable e) { if (markRollbackCause =3D=3D null) { markRollbackCause =3D e; } } So the first time the field is set to a "wrong" value and when the correct = value comes it's lost. I took stacktraces of both invocations. AFAIU the crucial bit is the Transa= ctionImpl.beforeCompletion(java.util.List) method. It first calls synch.bef= oreCompletion() and then markRollbackCause. The problem is that synch.befor= eCompletion gets to markRollbackCause first. Why? Is it known? Is it a bug?= Is it some misconfiguration? Is it supposed to be fixed in Karaf 3.0.3 and= its openjpa feature? Why does PersistenceExceptions$2.translate(java.lang.= RuntimeException) call EntityManager.setRollbackOnly()? The first markRollbackCause invocation (from the RuntimeExceptionTranslator= that calls EntityManager.setRollbackOnly): Thread [qtp1832761053-45] (Suspended (breakpoint at line 539 in org.apache.= geronimo.transaction.manager.TransactionImpl)) =20 owns: org.apache.geronimo.transaction.manager.TransactionImpl (id=3D152)= =20 owns: org.eclipse.rap.rwt.internal.util.SerializableLock (id=3D153) =20 org.apache.geronimo.transaction.manager.TransactionImpl.markRollbackCause= (java.lang.Throwable) line: 539 =20 org.apache.geronimo.transaction.manager.TransactionImpl.setRollbackOnly(j= ava.lang.Throwable) line: 134 =20 org.apache.geronimo.transaction.manager.TransactionImpl.setRollbackOnly()= line: 126 =20 org.apache.openjpa.ee.JNDIManagedRuntime.setRollbackOnly(java.lang.Throwa= ble) line: 71 =20 org.apache.openjpa.ee.AutomaticManagedRuntime.setRollbackOnly(java.lang.T= hrowable) line: 274 =20 org.apache.openjpa.kernel.BrokerImpl.setRollbackOnlyInternal(java.lang.Th= rowable) line: 1674 =20 org.apache.openjpa.kernel.BrokerImpl.setRollbackOnly(java.lang.Throwable)= line: 1654 =20 org.apache.openjpa.kernel.DelegatingBroker.setRollbackOnly(java.lang.Thro= wable) line: 981 =20 org.apache.openjpa.persistence.EntityManagerImpl.setRollbackOnly(java.lan= g.Throwable) line: 631 =20 org.apache.openjpa.persistence.PersistenceExceptions$2.translate(java.lan= g.RuntimeException) line: 76 =20 org.apache.openjpa.kernel.BrokerImpl.translateManagedCompletionException(= java.lang.RuntimeException) line: 2093 =20 org.apache.openjpa.kernel.BrokerImpl.beforeCompletion() line: 2027 =20 org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(= java.util.List) line: 527 =20 org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(= ) line: 511 =20 org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare() l= ine: 413 =20 org.apache.geronimo.transaction.manager.TransactionImpl.commit() line: 26= 2 =20 org.apache.aries.transaction.internal.AriesTransactionManagerImpl(org.apa= che.geronimo.transaction.manager.TransactionManagerImpl).commit() line: 252= =20 Proxy94d42c5b_f0da_4685_aa62_e265cec6c45a.commit() line: not available = =20 org.apache.aries.transaction.TransactionAttribute$4.finish(javax.transact= ion.TransactionManager, org.apache.aries.transaction.TransactionToken) line= : 94 =20 org.apache.aries.transaction.TxInterceptorImpl.postCallWithReturn(org.osg= i.service.blueprint.reflect.ComponentMetadata, java.lang.reflect.Method, ja= va.lang.Object, java.lang.Object) line: 85 =20 org.apache.aries.blueprint.proxy.Collaborator.postInvoke(java.lang.Object= , java.lang.Object, java.lang.reflect.Method, java.lang.Object) line: 105 = =20 Proxy8b595ed5_edc7_4490_8e6d_48b3560da384.update(somepackage.MasterData) = line: not available =20 The second one (directly from TransactionImpl): Thread [qtp1832761053-45] (Suspended (breakpoint at line 539 in org.apache.= geronimo.transaction.manager.TransactionImpl)) =20 owns: org.apache.geronimo.transaction.manager.TransactionImpl (id=3D152)= =20 owns: org.eclipse.rap.rwt.internal.util.SerializableLock (id=3D153) =20 org.apache.geronimo.transaction.manager.TransactionImpl.markRollbackCause= (java.lang.Throwable) line: 539 =20 org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(= java.util.List) line: 531 =20 org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(= ) line: 511 =20 org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare() l= ine: 413 =20 org.apache.geronimo.transaction.manager.TransactionImpl.commit() line: 26= 2 =20 org.apache.aries.transaction.internal.AriesTransactionManagerImpl(org.apa= che.geronimo.transaction.manager.TransactionManagerImpl).commit() line: 252= =20 Proxy94d42c5b_f0da_4685_aa62_e265cec6c45a.commit() line: not available = =20 org.apache.aries.transaction.TransactionAttribute$4.finish(javax.transact= ion.TransactionManager, org.apache.aries.transaction.TransactionToken) line= : 94 =20 org.apache.aries.transaction.TxInterceptorImpl.postCallWithReturn(org.osg= i.service.blueprint.reflect.ComponentMetadata, java.lang.reflect.Method, ja= va.lang.Object, java.lang.Object) line: 85 =20 org.apache.aries.blueprint.proxy.Collaborator.postInvoke(java.lang.Object= , java.lang.Object, java.lang.reflect.Method, java.lang.Object) line: 105 = =20 Proxy8b595ed5_edc7_4490_8e6d_48b3560da384.update(somepackage.MasterData) = line: not available =20 All kinds of comments welcome. --=20 Antoni My=C5=82ka Software Engineer Quantinum AG, Birkenweg 61, CH-3013 Bern - Fon +41 31 388 20 40 http://www.quantinum.com - Experience the Power of Data P.S. Versions of the relevant bundles 9 | Active | 20 | 1.1.0 | Apache Aries Util 10 | Active | 20 | 1.0.1 | Apache Aries Proxy API 11 | Active | 20 | 1.0.3 | Apache Aries Proxy Service 12 | Active | 20 | 1.0.1 | Apache Aries Blueprint API 13 | Active | 20 | 1.0.5 | Apache Aries Blueprint CM 14 | Resolved | 20 | 1.0.0 | Apache Aries Blueprint Core = Compatiblity Fragment Bundle, Hosts: 15 15 | Active | 20 | 1.4.1 | Apache Aries Blueprint Core,= Fragments: 14 71 | Active | 50 | 0 | wrap_mvn_postgresql_postgres= ql_9.1-901.jdbc4 76 | Active | 30 | 1.1.1 | geronimo-jta_1.1_spec 77 | Active | 30 | 1.0.1 | Annotation 1.1 96 | Active | 30 | 1.0.0 | Aries JPA Container API 97 | Active | 30 | 1.0.1 | Aries JPA Container blueprin= t integration for Aries blueprint 98 | Active | 30 | 1.0.0 | Aries JPA Container 99 | Active | 30 | 1.0.1 | Aries JPA Container Managed = Contexts 100 | Active | 30 | 1.0.1 | Apache Aries Transaction Blu= eprint 101 | Active | 30 | 1.1.0 | Apache Aries Transaction Man= ager 103 | Active | 30 | 3.0.2 | Apache Karaf :: JNDI :: Core 104 | Active | 30 | 1.0.0 | Apache Aries JNDI API 105 | Active | 30 | 1.0.0 | Apache Aries JNDI Core 106 | Active | 30 | 1.0.0 | Apache Aries JNDI RMI Handle= r 107 | Active | 30 | 1.0.0 | Apache Aries JNDI URL Handle= r 108 | Active | 30 | 1.0.0 | Apache Aries JNDI Support fo= r Legacy Runtimes 109 | Active | 80 | 3.0.2 | Apache Karaf :: JNDI :: Comm= and 118 | Active | 50 | 2.3.0 | OpenJPA Aggregate Jar