• Post Reply Bookmark Topic Watch Topic
  • New Topic

COMMIT is not allowed in a subordinate session

 
Bahadur Shah
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In My Servlet, I am using JTA transaction which is not a CMT.
I am running this on Oracle XADatasource.

When I'm trying to perform the DB operation, I'm getting the
Exception saying "COMMIT is not allowed in a subordinate session "

Any inputs on this please

My Servlet code is :



My Persistence.xml is
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue is probably related to you acquiring your EntityManager outside of the JTA transaction. Unless you use a managed (injected) EntityManager, it will be bound to only the JTA transaction that it was acquired in. You can use joinTransaction() to join a new JTA transaction.

So either move your initEM after the begin, or call joinTransaction, or inject the EM.

See,
http://en.wikibooks.org/wiki/Java_Persistence/Transactions#Join_Transaction
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!