It is possible to invoke two remote EJB targeting two remote server (each EJB in their own server) in the same distributed transaction? (cascanding calls)
I am using Wildfly 23 and for this situation, the container only invoke the first EJB invocation corretly, targeting the correct server. But when tries to invoke the second EJB, I'm getting error because Wildfly tries to lookup the second EJB targeting the first server, which is wrong. The correct behavior would be targeting the second server, as declared in <remote-ejb-receiver>.
This behavior becomes more strange because if I make the second invocation in a separate transaction (i.e. annotating the second remote EJB with @TransactionAttribute(REQUIRES_NEW)) all works fine.
The problem is that I can't change all the remote invocations to REQUIRES_NEW because I don't want to lose the atomicity of the whole transaction.
Follow the sequence diagram for this situations:

It is possible to achieve the second behavior but with just one transaction?
Hello,
Where is this defined? <remote-ejb-receiver>. , it looks like perhaps you meant you have a jboss-ejb-client.xml with something like:
<remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection"/>
that you have configured to point to server2 ? If so, then you have the EJB2 code specifying a provider url as well, so basically 2 different methods of invoking EJBs.
It looks like an issue is you have something like a booking.jar deployed in server1 and server2, but these are not the same deployment, as in server1 booking.jar has EJB1 & EJB2, but then in server2 it has EJB3 ? If this is the case, then the location mapping of EJBs is done based on the appName/moduleName , so Wildfly sees this as there is a booking.jar with EJB1, EJB2 & EJB3 when that is not the case. Changing the deployment name on server2 or using <distinct-name>... in the jboss-ejb3.xml and then changing the EJB lookup to include the distinct-name would allow it to distinguish between the 2 different deployments.
ejb:/booking/EJB1
ejb:/booking/EJB2
ejb:/booking/EJB3