I made several tests and I find the same conclusion.
So if anyone knows why the remote is used instead of the local, that will be nice ??
My solution is to use @EJB inject like that :
@EJB(mappedName = "masterServices/ResourcesSessionBean/local") private ResourcesSession resourcesSession;
I don't agree. Sure, this is a problem, but the solution is not try to optimize local over remote.
Such as solution would create a undeterministic situation where sometimes calls get done local (with call-by-value and, for example, entity classes still attached) and sometimes calls get done remote (with call-by-reference, for example, entity classes detached). It would create hard-to-maintain, hard-to-debug and strange-error-behavior code.
The solution is to either:
* Deny/Warn deploy of code where the same java interface is used for both local and remote EJB3 interface.
* Deny/Warn deploy of code that uses plain injection (without arguments) on a java interface that have multiple EJB3 interfaces.
The design pattern we applied after discovering this behavior in JBoss is to Never use the same java interface for local and remote EJB3 interface.