Hi Mihael,

difficult to say without the actual source.

The problem occurs when the coordination ends. So maybe this happens in a different thread. See https://osgi.org/javadoc/r5/enterprise/org/osgi/service/coordinator/Participant.html#ended%28org.osgi.service.coordinator.Coordination%29

"Participants are required to be thread safe as notification can be made on any thread. "

Can you paste the relevant code snippets of SalesProspectResource.update?

It might also help to update to the new Aries JPA 2.2.0 version. (Would be a bigger switch though).

Christian

On 08.10.2015 12:37, Mihael Schmidt wrote:
Hi,

I got a rest service where I am using multiple persistence units and data sources to store data in different databases using multiple transactions (I don't need all in one transaction). It all happens on multiple threads.

I am getting an exception on the last persist where I want to save some log in a database which happens on the same thread where the rest service starts (qtp18495206-81) . It seems that the EntityManager is cleared up before my call to persist. Is that the reason for the exception?

2015-10-08 12:20:46,025 | DEBUG | qtp18495206-81 | context | 108 - org.apache.aries.jpa.container.context - 1.0.4 | Created a new persistence context org.apache.openjpa.persistence.EntityManagerImpl@1d911f for transaction [Xid:globalId=f2e7446501006f72672e6170616368652e61726965732e7472616e73616374696f6e0000000000000000000000000000,length=64,branchId=0000000000000000000000000000000000000000000000000000000000000000,length=64]. 2015-10-08 12:20:46,183 | DEBUG | Thread-52 | context | 108 - org.apache.aries.jpa.container.context - 1.0.4 | Created a new persistence context org.apache.openjpa.persistence.EntityManagerImpl@1a615e2 for transaction [Xid:globalId=102e7446501006f72672e6170616368652e61726965732e7472616e73616374696f6e0000000000000000000000000000,length=64,branchId=0000000000000000000000000000000000000000000000000000000000000000,length=64]. 2015-10-08 12:20:46,186 | DEBUG | Thread-52 | context | 108 - org.apache.aries.jpa.container.context - 1.0.4 | Clearing up EntityManager org.apache.openjpa.persistence.EntityManagerImpl@1a615e2 as the transaction has completed. 2015-10-08 12:20:46,410 | DEBUG | Thread-52 | context | 108 - org.apache.aries.jpa.container.context - 1.0.4 | Created a new persistence context org.apache.openjpa.persistence.EntityManagerImpl@3fee6f for transaction [Xid:globalId=112e7446501006f72672e6170616368652e61726965732e7472616e73616374696f6e0000000000000000000000000000,length=64,branchId=0000000000000000000000000000000000000000000000000000000000000000,length=64]. 2015-10-08 12:20:46,413 | DEBUG | Thread-52 | context | 108 - org.apache.aries.jpa.container.context - 1.0.4 | Clearing up EntityManager org.apache.openjpa.persistence.EntityManagerImpl@3fee6f as the transaction has completed. 2015-10-08 12:20:46,491 | DEBUG | Thread-69 | context | 108 - org.apache.aries.jpa.container.context - 1.0.4 | Created a new persistence context org.apache.openjpa.persistence.EntityManagerImpl@c974a9 for transaction [Xid:globalId=122e7446501006f72672e6170616368652e61726965732e7472616e73616374696f6e0000000000000000000000000000,length=64,branchId=0000000000000000000000000000000000000000000000000000000000000000,length=64]. 2015-10-08 12:20:46,493 | DEBUG | Thread-69 | context | 108 - org.apache.aries.jpa.container.context - 1.0.4 | Clearing up EntityManager org.apache.openjpa.persistence.EntityManagerImpl@c974a9 as the transaction has completed. 2015-10-08 12:20:46,547 | DEBUG | qtp18495206-81 | context | 108 - org.apache.aries.jpa.container.context - 1.0.4 | Clearing up EntityManager org.apache.openjpa.persistence.EntityManagerImpl@1d911f as the transaction has completed. 2015-10-08 12:20:46,548 | DEBUG | qtp18495206-81 | CoordinationFilter | 178 - de.sgbs.sdm.rs <http://de.sgbs.sdm.rs> - 1.3.0 | Coordination ends 2015-10-08 12:20:46,548 | ERROR | qtp18495206-81 | TxLogParticipant | 184 - de.sgbs.sdm.txlog - 1.3.0 | Error on saving custom log javax.persistence.TransactionRequiredException: There is no currently active transaction. at org.apache.aries.jpa.container.context.transaction.impl.JTAPersistenceContextRegistry.ensureTransaction(JTAPersistenceContextRegistry.java:110) at org.apache.aries.jpa.container.context.transaction.impl.JTAPersistenceContextRegistry.getExistingPersistenceContext(JTAPersistenceContextRegistry.java:82) at org.apache.aries.jpa.container.context.transaction.impl.JTAPersistenceContextRegistry.getCurrentPersistenceContext(JTAPersistenceContextRegistry.java:139) at org.apache.aries.jpa.container.context.transaction.impl.JTAEntityManagerHandler.getPersistenceContext(JTAEntityManagerHandler.java:104) at org.apache.aries.jpa.container.context.transaction.impl.JTAEntityManagerHandler.invoke(JTAEntityManagerHandler.java:182)
at com.sun.proxy.$Proxy21.persist(Unknown Source)
at sdm.txlog.TxLogService.write(TxLogService.java:218)
at sdm.txlog.TxLogParticipant$1.run(TxLogParticipant.java:28)
at sdm.txlog.TxLogParticipant.ended(TxLogParticipant.java:31)
at org.apache.felix.coordinator.impl.CoordinationImpl.end(CoordinationImpl.java:205) at org.apache.felix.coordinator.impl.CoordinationHolder.end(CoordinationHolder.java:55)
at sdm.rs.CoordinationFilter.end(CoordinationFilter.java:144)
at sdm.rs.crm.SalesProspectResource.update(SalesProspectResource.java:187)
at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_75]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_75]
at org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63)[133:org.amdatu.web.rest.wink:2.0.2]

I am using transaction attribute "Required".

I am running Apache Karaf 3.0.3 with Aries JTA and OpenJPA 2.2.2.

Thanx in advance for any help or hint.

Best regards

Mihael

Schulz Gebäudeservice GmbH & Co. KG
Dr.-Max-Ilgner-Straße 17
32339 Espelkamp
        
Persönlich haftende Gesellschafterin:
Gebäudereinigung Joachim Schulz
Verwaltungsgesellschaft mbH
Telefon: +49 5772 9100 0
Telefax: +49 5772 9100 11
Email: zentr...@sgbs.de <mailto:zentr...@sgbs.de>
Internet: www.sgbs.de <http://www.sgbs.de/>
        
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
Handelsregister Bad Oeynhausen: HRA 5902, HRB 8591
UST-Id-Nr.: DE 125752702



--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply via email to