Assume a single application server instance that has two EARs deployed. The first EAR invokes EJBs from the second EAR using remote EJB interfaces.
It is rumored that even if the invokation is implemented using remote interfaces, the application server knows that everything is within the same JVM and internally uses the remote interface with local interface mechanics, namely it does not call methods through RMI, does not open any sockets, and does not serialize/deserialize objects.
Is this true? If anybody has feedback on the behaviour of Weblogic 10.3.2 and OC4j 10.1.3 regarding this issue, it would be much appreciated.
No, it is not true. If the ORB implements local object optimization (sometimes “collocated objects”), then it will not open any sockets, but it will perform serialization/deserialization, which is typically faster than marshalling. The extra object copies are made to avoid violating the programming model.
Generated stubs enable this optimization. Here is an example interface:
Here is the result of rmic -iiop -keep a:
When a stub is connected to a local object, it calls ObjectImpl._servant_preinvoke to locate a servant (an EJB wrapper in your case) within the same JVM. Then, it makes a copy of the input arguments (simulating marshalling), calls the method, and makes a copy of the result object (again simulating marshalling).
I am not a WebLogic expert. That said, this document implies that WebLogic performs the collocated object optimization:
http://download.oracle.com/docs/cd/E13222_01/wls/docs61/cluster/object.html#1007328