Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic