You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Mihael Schmidt <ms...@sgbs.de> on 2015/10/08 12:37:22 UTC
No currently active transaction
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 - 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: zentrale@sgbs.de
Internet: www.sgbs.de
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
Handelsregister Bad Oeynhausen: HRA 5902, HRB 8591
UST-Id-Nr.: DE 125752702
Re: No currently active transaction
Posted by Mihael Schmidt <ms...@sgbs.de>.
Man ... you are my savior. That worked out-of-the-box ( as it should =D ).
Puuhhhh... now I can finally move on =)
2015-10-08 16:14 GMT+02:00 Christian Schneider <ch...@die-schneider.net>:
> I think what the system says is that you are trying to do a write to the
> database while not inside a jta transaction.
>
> As a workaround you can try to inject UserTransaction and begin and commit
> the transaction yourself.
>
> Christian
>
>
> On 08.10.2015 16:01, Mihael Schmidt wrote:
>
>> What I don't get here is that the system says "no active transaction" but
>> I am calling a service which is the only service with this
>> entitymanager(factory) assigned and it hasn't been doing any calls to the
>> database (till I get the exception).
>>
>> The transactions wouldn't even be nested. They would occur one after
>> another. It seems that the system says: "no more than one connection. nope
>> ... not you, you are the second. come back tomorrow".
>>
>> Threading shouldn't be a problem as all the other transactions did commit
>> successfully.
>>
>>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>
>
--
Mihael Schmidt
Software und System-Entwicklung
--
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: zentrale@sgbs.de
Internet: www.sgbs.de
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
Handelsregister Bad Oeynhausen: HRA 5902, HRB 8591
UST-Id-Nr.: DE 125752702
Re: No currently active transaction
Posted by Christian Schneider <ch...@die-schneider.net>.
I think what the system says is that you are trying to do a write to the
database while not inside a jta transaction.
As a workaround you can try to inject UserTransaction and begin and
commit the transaction yourself.
Christian
On 08.10.2015 16:01, Mihael Schmidt wrote:
> What I don't get here is that the system says "no active transaction"
> but I am calling a service which is the only service with this
> entitymanager(factory) assigned and it hasn't been doing any calls to
> the database (till I get the exception).
>
> The transactions wouldn't even be nested. They would occur one after
> another. It seems that the system says: "no more than one connection.
> nope ... not you, you are the second. come back tomorrow".
>
> Threading shouldn't be a problem as all the other transactions did
> commit successfully.
>
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
http://www.talend.com
Re: No currently active transaction
Posted by Mihael Schmidt <ms...@sgbs.de>.
What I don't get here is that the system says "no active transaction" but I
am calling a service which is the only service with this
entitymanager(factory) assigned and it hasn't been doing any calls to the
database (till I get the exception).
The transactions wouldn't even be nested. They would occur one after
another. It seems that the system says: "no more than one connection. nope
... not you, you are the second. come back tomorrow".
Threading shouldn't be a problem as all the other transactions did commit
successfully.
2015-10-08 15:26 GMT+02:00 Christian Schneider <ch...@die-schneider.net>:
> It should not matter as long as the transaction should not span several
> calls.
>
> Christian
>
>
>
> On 08.10.2015 14:14, Mihael Schmidt wrote:
>
> Does it matter from which thread i am calling the service?
>
> 2015-10-08 14:07 GMT+02:00 Christian Schneider <ch...@die-schneider.net>:
>
>> The transactional interceptor only works when the txLogService is
>> instantiated by blueprint. Maybe at some point you are working with an
>> unproxied instance.
>>
>> Christian
>>
>> On 08.10.2015 14:01, Mihael Schmidt wrote:
>>
>>> TxLogService is create via blueprint. TxLogParticipant calls
>>> TxLogService which is passed as a parameter to TxLogParticipant.
>>>
>>> CoordinationFilter is create via DS.
>>>
>>> I don't know if it helps but entityManager.isOpen() returns true.
>>>
>>> Mihael
>>>
>>>
>> --
>> Christian Schneider
>> http://www.liquid-reality.de
>>
>> Open Source Architect
>> http://www.talend.com
>>
>>
>
>
> --
> Mihael Schmidt
> Software und System-Entwicklung
>
> 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: <ze...@sgbs.de>zentrale@sgbs.de
> Internet: <http://www.sgbs.de/>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 Schneiderhttp://www.liquid-reality.de
>
> Open Source Architecthttp://www.talend.com
>
>
--
Mihael Schmidt
Software und System-Entwicklung
--
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: zentrale@sgbs.de
Internet: www.sgbs.de
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
Handelsregister Bad Oeynhausen: HRA 5902, HRB 8591
UST-Id-Nr.: DE 125752702
Re: No currently active transaction
Posted by Christian Schneider <ch...@die-schneider.net>.
It should not matter as long as the transaction should not span several
calls.
Christian
On 08.10.2015 14:14, Mihael Schmidt wrote:
> Does it matter from which thread i am calling the service?
>
> 2015-10-08 14:07 GMT+02:00 Christian Schneider
> <chris@die-schneider.net <ma...@die-schneider.net>>:
>
> The transactional interceptor only works when the txLogService is
> instantiated by blueprint. Maybe at some point you are working
> with an unproxied instance.
>
> Christian
>
> On 08.10.2015 14:01, Mihael Schmidt wrote:
>
> TxLogService is create via blueprint. TxLogParticipant calls
> TxLogService which is passed as a parameter to TxLogParticipant.
>
> CoordinationFilter is create via DS.
>
> I don't know if it helps but entityManager.isOpen() returns true.
>
> Mihael
>
>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>
>
>
>
> --
> Mihael Schmidt
> Software und System-Entwicklung
>
> 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: zentrale@sgbs.de <ma...@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
Re: No currently active transaction
Posted by Mihael Schmidt <ms...@sgbs.de>.
Does it matter from which thread i am calling the service?
2015-10-08 14:07 GMT+02:00 Christian Schneider <ch...@die-schneider.net>:
> The transactional interceptor only works when the txLogService is
> instantiated by blueprint. Maybe at some point you are working with an
> unproxied instance.
>
> Christian
>
> On 08.10.2015 14:01, Mihael Schmidt wrote:
>
>> TxLogService is create via blueprint. TxLogParticipant calls TxLogService
>> which is passed as a parameter to TxLogParticipant.
>>
>> CoordinationFilter is create via DS.
>>
>> I don't know if it helps but entityManager.isOpen() returns true.
>>
>> Mihael
>>
>>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>
>
--
Mihael Schmidt
Software und System-Entwicklung
--
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: zentrale@sgbs.de
Internet: www.sgbs.de
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
Handelsregister Bad Oeynhausen: HRA 5902, HRB 8591
UST-Id-Nr.: DE 125752702
Re: No currently active transaction
Posted by Christian Schneider <ch...@die-schneider.net>.
The transactional interceptor only works when the txLogService is
instantiated by blueprint. Maybe at some point you are working with an
unproxied instance.
Christian
On 08.10.2015 14:01, Mihael Schmidt wrote:
> TxLogService is create via blueprint. TxLogParticipant calls
> TxLogService which is passed as a parameter to TxLogParticipant.
>
> CoordinationFilter is create via DS.
>
> I don't know if it helps but entityManager.isOpen() returns true.
>
> Mihael
>
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
http://www.talend.com
Re: No currently active transaction
Posted by Mihael Schmidt <ms...@sgbs.de>.
TxLogService is create via blueprint. TxLogParticipant calls TxLogService
which is passed as a parameter to TxLogParticipant.
CoordinationFilter is create via DS.
I don't know if it helps but entityManager.isOpen() returns true.
Mihael
2015-10-08 13:56 GMT+02:00 Christian Schneider <ch...@die-schneider.net>:
> Hi Mihael,
>
> I do not see any calls to txLogService in this snippet. Is it called in
> coordinationFilter?
> If yes then the question is how coordinationFilter is instantiated and how
> the txLogService is injected into it.
>
> Christian
>
>
> On 08.10.2015 13:49, Mihael Schmidt wrote:
>
> Hi,
>
> the coordination is handled on the same thread (as you can see in the log,
> TxLogParticipant logs on the same thread, the participant calls the service
> which persists data to the db).
>
> REST resource:
> try {
> // check permission
> Coordination coordination = coordinator.peek();
> User user = (User) coordination.getVariables().get(User.class);
> if (!user.getRoles().contains("xx.xx")) {
> coordinationFilter.fail(new
> WebApplicationException(Status.UNAUTHORIZED));
> throw new WebApplicationException(Status.UNAUTHORIZED);
> }
>
> try {
> SalesProspect updatedPospect = service.update(prospect);
> return Response.ok(updatedPospect).build();
> }
> catch(Exception e) {
> logger.error("Fehler beim Aktualisieren des Interessenten
> " + prospect.getName(), e);
> coordinationFilter.fail(e);
> throw new
> WebApplicationException(Status.INTERNAL_SERVER_ERROR);
> }
> }
> finally {
> coordinationFilter.end();
> }
>
> My real question is: why isn't a new transaction created if none is
> active. The transaction attribute is "Required":
> <bean id="txlogService" class="sdm.txlog.TxLogService">
> <tx:transaction method="*" value="Required" />
> <jpa:context property="entityManager" unitname="sdmTxlog" />
> </bean>
>
> Best regards
>
> Mihael
>
>
> 2015-10-08 13:14 GMT+02:00 Christian Schneider <ch...@die-schneider.net>:
>
>> 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 - 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 <%2B49%205772%209100> 0
>> Telefax: +49 5772 9100 <%2B49%205772%209100> 11
>> Email: <ze...@sgbs.de>zentrale@sgbs.de
>> Internet: <http://www.sgbs.de>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 Schneiderhttp://www.liquid-reality.de
>>
>> Open Source Architecthttp://www.talend.com
>>
>>
>
>
> --
> Mihael Schmidt
> Software und System-Entwicklung
>
> 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: <ze...@sgbs.de>zentrale@sgbs.de
> Internet: <http://www.sgbs.de/>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 Schneiderhttp://www.liquid-reality.de
>
> Open Source Architecthttp://www.talend.com
>
>
--
Mihael Schmidt
Software und System-Entwicklung
--
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: zentrale@sgbs.de
Internet: www.sgbs.de
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
Handelsregister Bad Oeynhausen: HRA 5902, HRB 8591
UST-Id-Nr.: DE 125752702
Re: No currently active transaction
Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Mihael,
I do not see any calls to txLogService in this snippet. Is it called in
coordinationFilter?
If yes then the question is how coordinationFilter is instantiated and
how the txLogService is injected into it.
Christian
On 08.10.2015 13:49, Mihael Schmidt wrote:
> Hi,
>
> the coordination is handled on the same thread (as you can see in the
> log, TxLogParticipant logs on the same thread, the participant calls
> the service which persists data to the db).
>
> REST resource:
> try {
> // check permission
> Coordination coordination = coordinator.peek();
> User user = (User)
> coordination.getVariables().get(User.class);
> if (!user.getRoles().contains("xx.xx")) {
> coordinationFilter.fail(new WebApplicationException(Status.UNAUTHORIZED));
> throw new WebApplicationException(Status.UNAUTHORIZED);
> }
> try {
> SalesProspect updatedPospect = service.update(prospect);
> return Response.ok(updatedPospect).build();
> }
> catch(Exception e) {
> logger.error("Fehler beim Aktualisieren des Interessenten " +
> prospect.getName(), e);
> coordinationFilter.fail(e);
> throw new
> WebApplicationException(Status.INTERNAL_SERVER_ERROR);
> }
> }
> finally {
> coordinationFilter.end();
> }
>
> My real question is: why isn't a new transaction created if none is
> active. The transaction attribute is "Required":
> <bean id="txlogService" class="sdm.txlog.TxLogService">
> <tx:transaction method="*" value="Required" />
> <jpa:context property="entityManager" unitname="sdmTxlog" />
> </bean>
>
> Best regards
>
> Mihael
>
>
> 2015-10-08 13:14 GMT+02:00 Christian Schneider
> <chris@die-schneider.net <ma...@die-schneider.net>>:
>
> 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 <tel:%2B49%205772%209100> 0
>> Telefax: +49 5772 9100 <tel:%2B49%205772%209100> 11
>> Email: zentrale@sgbs.de <ma...@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
>
>
>
>
> --
> Mihael Schmidt
> Software und System-Entwicklung
>
> 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: zentrale@sgbs.de <ma...@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
Re: No currently active transaction
Posted by Mihael Schmidt <ms...@sgbs.de>.
Hi,
the coordination is handled on the same thread (as you can see in the log,
TxLogParticipant logs on the same thread, the participant calls the service
which persists data to the db).
REST resource:
try {
// check permission
Coordination coordination = coordinator.peek();
User user = (User) coordination.getVariables().get(User.class);
if (!user.getRoles().contains("xx.xx")) {
coordinationFilter.fail(new
WebApplicationException(Status.UNAUTHORIZED));
throw new WebApplicationException(Status.UNAUTHORIZED);
}
try {
SalesProspect updatedPospect = service.update(prospect);
return Response.ok(updatedPospect).build();
}
catch(Exception e) {
logger.error("Fehler beim Aktualisieren des Interessenten "
+ prospect.getName(), e);
coordinationFilter.fail(e);
throw new
WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
}
finally {
coordinationFilter.end();
}
My real question is: why isn't a new transaction created if none is active.
The transaction attribute is "Required":
<bean id="txlogService" class="sdm.txlog.TxLogService">
<tx:transaction method="*" value="Required" />
<jpa:context property="entityManager" unitname="sdmTxlog" />
</bean>
Best regards
Mihael
2015-10-08 13:14 GMT+02:00 Christian Schneider <ch...@die-schneider.net>:
> 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 - 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: <ze...@sgbs.de>zentrale@sgbs.de
> Internet: <http://www.sgbs.de/>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 Schneiderhttp://www.liquid-reality.de
>
> Open Source Architecthttp://www.talend.com
>
>
--
Mihael Schmidt
Software und System-Entwicklung
--
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: zentrale@sgbs.de
Internet: www.sgbs.de
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
Handelsregister Bad Oeynhausen: HRA 5902, HRB 8591
UST-Id-Nr.: DE 125752702
Re: No currently active transaction
Posted by Christian Schneider <ch...@die-schneider.net>.
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: zentrale@sgbs.de <ma...@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