You can use EJB local invocations in servlet, JSP, or EJB component code to call EJB components hosted on the same server. Proxies for a local bean can be instantiated with almost the same code that would be used to instantiate remote proxies. The differences are:
You must create a local EJB reference for the called EJB component, and use the aliased JNDI name defined in the EJB local reference.
Parameters that are not primitive types are passed by reference, not by value. Changes to a parameter in the component implementation affect the variable passed from the caller.
You must narrow to the local home interface type, not the home interface type.
Local interfaces are available only to EJB components, Java servlets, and JSPs hosted on the same server as the target component.
If local interfaces are used, both the caller and the called component must be loaded by the same custom class loader.
When an EJB 2.0 component provides local interfaces, any other component or Web application that calls the local interface must use the same class loader. ClassCastException errors occur when local interface calls are made from entities that use a different class loader. Configure the custom class lists for the calling and called components and parent entries to allow sharing of the class instances as described in Chapter 10, “Configuring Java Class Loaders,” in the System Administration Guide.