-
1. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
tomjenkinson Aug 4, 2016 8:32 AM (in response to serg_732173)I moved this to the WildFly space as I expect this is EJB related if there is an issue. Please provide logs for both runs and the version of WildFly you are using.
-
2. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
serg_732173 Aug 4, 2016 9:15 AM (in response to tomjenkinson)i haven't old logs. i used @TransactionAttribute(REQUIRES_NEW).
New log is no detailed and can contain wrong info.
Version is Wildfly 9.0.1.Final.
I have meant what is right operating. What must happen in this case.
Can method from ejb2 see results that were saved by ejb1?
or this transaction is no commited (is there only one global transaction of client?) and info that was saved by ejb1 is no visible for ejb2 too...
-
3. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
serg_732173 Aug 4, 2016 3:06 PM (in response to serg_732173)is it partially "diamond scenario" in transactions?
-
5. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
serg_732173 Aug 11, 2016 8:08 AM (in response to tomjenkinson)i haven't made experiments with isolation level. if it is reason and if dirty read had to be configured. it is question about isolations levels too.
-
6. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
serg_732173 Aug 11, 2016 8:19 AM (in response to serg_732173)Can method from ejb2 see results that were saved by ejb1 in default configuration without explicit definitions of isolations levels?
-
7. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
ochaloup Aug 11, 2016 8:21 AM (in response to serg_732173)Hi,
have you tried to use @EJB annotation for injection instead of @Inject one? Does it get you the same results?
Could not be some beating between EJB and CDI processing? Do you annotate the second bean (ejb2) only with @Stateless annotation? Or in case would you be able to provide snippet of your ejbs to be easier to understand how is the ejbs used?
Ondra
-
8. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
serg_732173 Aug 11, 2016 8:50 AM (in response to ochaloup)SecondBean was annotated only with @Stateless
If it helps ("do" is called in EjbService by client. and more nested scenarios are possible):
___________
...
@Stateless
public class EjbService {
@Inject
private Ejb1 ejb1;
@Inject
private Ejb2 ejb2;
....
public do(){
ejb1.createA();
ejb2.processA();
}
}
_______________________
...
@Stateless
public class Ejb1 {
..
public createA(){ // write/create record *
...
}
}
__________________
...
@Stateless
public class Ejb2 {
....
public processA(){
readA..; // read record *
expandA..; // process record *
writeA....; // write record *
...
}
}
-
9. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
ochaloup Aug 11, 2016 10:33 AM (in response to serg_732173)Hi,
Based on your snippet I've created a simple reproducer and works smoothly for me.
To sum it up the error message means that there is no transaction at time when ejb2 does it's work. It means somebody had to cancel it somehow. I think it would be worthy to start trace logging on narayana.
<logger category="com.arjuna"> <level name="TRACE"/> </logger>
and then look what happens with the transaction started in bean ejb1.
There are one thing which came to my mind - what happens at call of ejb1 createA(). Don't you use there some DDL commands (e.g. create table)? Btw. what database do you work with?
-
10. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
ochaloup Aug 11, 2016 10:38 AM (in response to serg_732173)Can method from ejb2 see results that were saved by ejb1 in default configuration without explicit definitions of isolations levels?
If ejb2 is in the same transaction then it should be able to see the results. For example default isolation level for Oracle should be READ COMMITTED. It means if ejb2 is running under REQUIRES_NEW then ejb2 should not see changes (insertion) done by ejb1.
-
11. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
serg_732173 Aug 11, 2016 11:07 AM (in response to ochaloup)MySQL and Hibernate are used. Simple read,update, create (find, merge) entity are used. thanks
-
12. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
ochaloup Aug 11, 2016 11:35 AM (in response to serg_732173)ok, then I would not expect there should be a trouble. Is the persistence unit defined to be jta?
I think you will need to check server log to find out where transaction disappears. Or you can try to add to the end (and start) of each ejb method some manual logging like
@Resource(mappedName = "java:jboss/TransactionManager") protected TransactionManager tm; log.info("Currently under transaction " + tm.getTransaction() + " in status " + tm.getStatus());
to get idea what is status of the transaction managed by TM in which place.
Or could be that some error (exception thrown from jdbc driver or hibernate) happens in ejb1? Could be then that the connected global transaction is canceled.
-
13. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
serg_732173 Aug 12, 2016 8:26 AM (in response to ochaloup)thanks. to my sorrow i can not reproduce this case now exactly. Is it possible to show actual isolation level in called method?
-
14. Re: Nested Transactions. Nested call of EJBs from call of client from frontend
ochaloup Aug 12, 2016 9:37 AM (in response to serg_732173)There isn't way how to find out the isolation level per method with a standard Java EE api what I know. There isn't either any WildFly specific api to get that information but I'm not 100% sure here.
Either way you can touch the connection and ask about the isolation level directly on it.
As side note: default isolation level can be configured for hibernate in persistence.xml for particular persistence unit.
Another side note: isolation level is specific for databases. There is no such thing in jms connection for example.