We have 3 EJB to handle our business, as below:
@Stateless
public class BeanA {
@PersistenceContext(unitName = "primary")
private EntityManager em;
@EJB private BeanB beanB;
public void handle() {
EntityA entity= new EntityA();
....
beanB.handle();
em.persist(entity); //Transaction does not rollback and saved entity
}
}
@Stateless
public class BeanB {
@EJB private BeanC beanC;
public void handle() {
beanC.handle();
}
}
@Stateless
public class BeanC {
public void handle() {
try {
throw new RunTimeException("error occurred!!");
} catch(RunTimeException e) {
e.printStacktrace();
}
}
}
According to JTA concept that if occurred RuntimeExcpetion the current transaction will be rollback,I expected that above transaction should be rollback but does not rollback. also we use Wildfly10 as Application server and active JTA="true" option in datasources.
Is there any idea about this problem?