[ 
https://issues.apache.org/jira/browse/OLINGO-976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15360860#comment-15360860
 ] 

Alex Key commented on OLINGO-976:
---------------------------------

Hi Michael,

here are my thoughts.
# First of all, our goal here is to integrate Olingo with JTA persistence 
unit/EntityManager. Here we aren’t talking about integration using container 
managed transactions or bean managed transactions. Main goal is JTA.
# Now about transactions - Olingo is not using EJB container (only web 
container is a requirement). Therefore, container managed transactions can’t be 
used here. But we can use bean managed transactions. To do that (in a 
thread-safe way) we need to JNDI lookup entity manager (for JPA calls) and user 
transaction (for JTA calls) on each HTTP request.

JNDI name “java:comp/UserTransaction” needs to be used to lookup 
UserTransaction (standard according to the specification). Olingo will need 
optional dependency on JTA library to use UserTransaction class 
(https://mvnrepository.com/artifact/javax.transaction/jta). I also propose to 
rename ODataJPATransactionContainerManaged to ODataJPATransactionJTA and do 
JNDI lookup there (via utility class).

JNDI name of EntityManager will need to be passed by Olingo user. User also 
needs to define persistence-context-ref in web.xml. JNDI lookup can be made via 
the same lookup utility class as in UserTransaction lookup.

Best regards,
Alex

P.S. I've linked OLINGO-971 as both are about the same topic.

> Problem with JTA transactions
> -----------------------------
>
>                 Key: OLINGO-976
>                 URL: https://issues.apache.org/jira/browse/OLINGO-976
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.7
>         Environment: neo-javaee6-wp-sdk (SAP HANA cloud)
>            Reporter: Alex Key
>            Assignee: Michael Bolz
>             Fix For: V2 2.0.7
>
>
> There are still problems with JTA transaction after fixing OLINGO-882.
> At the moment IllegalStateException is thrown by 
> ODataJPATransactionLocalDefault constructor, which has em.getTransaction() 
> call.
> Here's stacktrace:
> {code}
> java.lang.IllegalStateException: A JTA EntityManager can not use the 
> EntityTransaction API.  See JPA 1.0 section 5.5
>       at 
> org.apache.openejb.persistence.JtaEntityManager.getTransaction(JtaEntityManager.java:349)
>       at 
> org.apache.olingo.odata2.jpa.processor.core.ODataJPATransactionLocalDefault.<init>(ODataJPATransactionLocalDefault.java:31)
>       at 
> org.apache.olingo.odata2.jpa.processor.core.ODataJPAContextImpl.getODataJPATransaction(ODataJPAContextImpl.java:178)
>       at 
> org.apache.olingo.odata2.jpa.processor.core.access.data.JPAProcessorImpl.setTransaction(JPAProcessorImpl.java:451)
>       at 
> org.apache.olingo.odata2.jpa.processor.core.access.data.JPAProcessorImpl.processCreate(JPAProcessorImpl.java:335)
>       at 
> org.apache.olingo.odata2.jpa.processor.core.access.data.JPAProcessorImpl.process(JPAProcessorImpl.java:223)
>       at 
> org.apache.olingo.odata2.jpa.processor.core.ODataJPAProcessorDefault.createEntity(ODataJPAProcessorDefault.java:122)
>       at org.apache.olingo.odata2.core.Dispatcher.dispatch(Dispatcher.java:79)
>       at 
> org.apache.olingo.odata2.core.ODataRequestHandler.handle(ODataRequestHandler.java:130)
>       at 
> org.apache.olingo.odata2.core.rest.ODataSubLocator.handle(ODataSubLocator.java:164)
>       at 
> org.apache.olingo.odata2.core.rest.ODataSubLocator.handlePost(ODataSubLocator.java:86)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to