We use wildfly12 and use datasource with jta=false
in our ejb we have transaction attribute NEVER
but thrown exception during call another ejb class with transaction attribute NEVER
, the exception as below:
Transaction present on server in Never call
according to below link
Transaction present on server in Never call
we known that we can't method call from ejb that has transaction attribute NEVER
, but we set jta=false
, i expected that transaction manager does not work.
Unfortunately the jta=false
being set at datasource does not mean that transaction is not started. What that means is the datasource won't be part of the transaction. If not said differently the CTM EJB component starts transaction in any case. So the transaction is started and then the transaction context is propagated to any EJB method that the component calls.
A note: the transaction can be suspended for the time the method is processed (https://docs.oracle.com/cd/E19226-01/820-7627/bncik/index.html) but resumed at time the method finishes.
Back to the jta=false
case. If you set the jta=false
at the method entry the CMT EJB starts the global transaction. When you use such datasource in the method the datasource is not enlisted to the global transaction. That means all data changes are committed immediately.
If you set the jta=true
then the datasource is enlisted to the transaction and the commit on data changes is run at time the transaction manager says (which is usually at the end of the EJB method).
If you want to call the method annotated with the TransactionAttributeType.NEVER
you really need to ensure the originated method does start/resume the transaction and does not propagate the transaction context.