Re: OpenJPA, Aries Transaction BluePrint, Can only perform operation while a transaction is active

2018-05-16 Thread Christian Schneider
Are you maybe calling this method from the same class? In this case the
interceptor that does the transaction management is not invoked.

Christian

2018-05-16 15:44 GMT+02:00 Alex Soto :

> Hello,
>
> I am trying to get transaction support for my JPA project.  I get this
> error:
>
> Caused by: org.apache.openjpa.persistence.TransactionRequiredException:
> Can only perform operation while a transaction is active.
> at 
> org.apache.openjpa.kernel.BrokerImpl.assertActiveTransaction(BrokerImpl.java:4723)
> ~[?:?]
> at 
> org.apache.openjpa.kernel.DelegatingBroker.assertActiveTransaction(DelegatingBroker.java:1385)
> ~[?:?]
> at org.apache.openjpa.persistence.EntityManagerImpl.
> flush(EntityManagerImpl.java:663) ~[?:?]
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
> at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:62) ~[?:?]
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43) ~[?:?]
> at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
> at org.apache.aries.jpa.support.osgi.impl.EmProxy.invoke(EmProxy.java:43)
> ~[?:?]
> at com.sun.proxy.$Proxy94.flush(Unknown Source) ~[?:?]
> at Proxy1e882fa8_f541_465e_9200_58ace778aff6.flush(Unknown Source)
> ~[?:?]
>
> My Blueprint XML is:
>
> http://www.osgi.org/xmlns/blueprint/v1.0.0;
> xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0;
> xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0;
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
> xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd;>
>
> 
> 
>
> 
>
> 
>
> 
>
>
> My Service:
>
> import static javax.transaction.Transactional.TxType.REQUIRED;
> import static javax.transaction.Transactional.TxType.SUPPORTS;
> import javax.transaction.Transactional;
> ...
> @Override
> @Transactional(REQUIRED)
> public void updateUser(User user) {
> em.persist(user);
> em.flush();
> }
>
> Log file shows the interceptor:
>
> 48 - org.apache.aries.transaction.blueprint - 1.1.1 | Component
> userService.addUser is txType Supports.
> 48 - org.apache.aries.transaction.blueprint - 1.1.1 | PreCall for bean
> userService, method addUser with tx strategy SUPPORTS.
> 43 - org.apache.aries.jpa.blueprint - 2.6.1 | PreCall for bean
> userService, method addUser
> 45 - org.apache.aries.jpa.support - 2.6.1 | Creating EntityManager for
> persistence unit responderPersistenUnit, coordination
> txInterceptor.org.data.service.UserService.addUser
> 43 - org.apache.aries.jpa.blueprint - 2.6.1 | PostCallWithException for
> bean userService, method addUser
> org.apache.openjpa.persistence.TransactionRequiredException: Can only
> perform operation while a transaction is active.
> at 
> org.apache.openjpa.kernel.BrokerImpl.assertActiveTransaction(BrokerImpl.java:4723)
> ~[?:?]
> at 
> org.apache.openjpa.kernel.DelegatingBroker.assertActiveTransaction(DelegatingBroker.java:1385)
> ~[?:?]
> at org.apache.openjpa.persistence.EntityManagerImpl.
> flush(EntityManagerImpl.java:663) ~[?:?]
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
> at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:62) ~[?:?]
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43) ~[?:?]
> at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
> at org.apache.aries.jpa.support.osgi.impl.EmProxy.invoke(EmProxy.java:43)
> ~[?:?]
> at com.sun.proxy.$Proxy94.flush(Unknown Source) ~[?:?]
> at Proxy1e882fa8_f541_465e_9200_58ace778aff6.flush(Unknown Source)
> ~[?:?]
>
>
> Any idea how to make it work or troubleshoot this?
> Versions:
>
> org.apache.aries.transaction.blueprint: 1.1.1
> org.apache.aries.jpa.blueprint:  2.6.1
> OpenJPA:  2.4.2
>
>
> Thanks in advance
>
> --
> --
> --
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ops4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



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

Computer Scientist
http://www.adobe.com

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


OpenJPA, Aries Transaction BluePrint, Can only perform operation while a transaction is active

2018-05-16 Thread Alex Soto
Hello,

I am trying to get transaction support for my JPA project.  I get this 
error:

Caused by: org.apache.openjpa.persistence.TransactionRequiredException: Can 
only perform operation while a transaction is active.
at 
org.apache.openjpa.kernel.BrokerImpl.assertActiveTransaction(BrokerImpl.java:4723)
 
~[?:?]
at 
org.apache.openjpa.kernel.DelegatingBroker.assertActiveTransaction(DelegatingBroker.java:1385)
 
~[?:?]
at 
org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:663)
 
~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[?:?]
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 
~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at 
org.apache.aries.jpa.support.osgi.impl.EmProxy.invoke(EmProxy.java:43) 
~[?:?]
at com.sun.proxy.$Proxy94.flush(Unknown Source) ~[?:?]
at Proxy1e882fa8_f541_465e_9200_58ace778aff6.flush(Unknown Source) 
~[?:?]

My Blueprint XML is:

http://www.osgi.org/xmlns/blueprint/v1.0.0;
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0;
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd;>




 
  



My Service:

import static javax.transaction.Transactional.TxType.REQUIRED;
import static javax.transaction.Transactional.TxType.SUPPORTS;
import javax.transaction.Transactional;
...
@Override
@Transactional(REQUIRED)
public void updateUser(User user) {
em.persist(user);
em.flush();
}

Log file shows the interceptor:

48 - org.apache.aries.transaction.blueprint - 1.1.1 | Component 
userService.addUser is txType Supports.
48 - org.apache.aries.transaction.blueprint - 1.1.1 | PreCall for bean 
userService, method addUser with tx strategy SUPPORTS.
43 - org.apache.aries.jpa.blueprint - 2.6.1 | PreCall for bean userService, 
method addUser
45 - org.apache.aries.jpa.support - 2.6.1 | Creating EntityManager for 
persistence unit responderPersistenUnit, coordination 
txInterceptor.org.data.service.UserService.addUser
43 - org.apache.aries.jpa.blueprint - 2.6.1 | PostCallWithException for 
bean userService, method addUser
org.apache.openjpa.persistence.TransactionRequiredException: Can only 
perform operation while a transaction is active.
at 
org.apache.openjpa.kernel.BrokerImpl.assertActiveTransaction(BrokerImpl.java:4723)
 
~[?:?]
at 
org.apache.openjpa.kernel.DelegatingBroker.assertActiveTransaction(DelegatingBroker.java:1385)
 
~[?:?]
at 
org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:663)
 
~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[?:?]
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 
~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at 
org.apache.aries.jpa.support.osgi.impl.EmProxy.invoke(EmProxy.java:43) 
~[?:?]
at com.sun.proxy.$Proxy94.flush(Unknown Source) ~[?:?]
at Proxy1e882fa8_f541_465e_9200_58ace778aff6.flush(Unknown Source) 
~[?:?]


Any idea how to make it work or troubleshoot this?
Versions:

org.apache.aries.transaction.blueprint: 1.1.1
org.apache.aries.jpa.blueprint:  2.6.1
OpenJPA:  2.4.2


Thanks in advance

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.