• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

The regular Home Interface uses RMI-IIOP for network communication—even when the client and bean are in the same JVM. This adds unnecessary overhead (serialization, network stack) for local calls.

Core Idea

The Local Home Interface (javax.ejb.EJBLocalHome) is the high-performance version of the Home Interface. It’s used when the client and bean are in the same JVM—no network calls, no RemoteException, direct memory access.

How It Works

  1. Extends EJBLocalHome: Unlike regular Home which extends EJBHome (which extends java.rmi.Remote)
  2. No RemoteException: Since there’s no network call, there’s no possibility of network failure
  3. Returns Local Interface: create() returns HelloLocal (local interface), not remote
  4. Fast: Uses pass-by-reference semantics within the same JVM

Visual Explanation

LocalHome cluster_same_jvm Same JVM C Client Code LH Local Home Object (EJBLocalHome) C->LH 1. create() LL Local EJB Object (EJBLocalObject) LH->LL 2. Return Local Object Bean Enterprise Bean LL->Bean 3. Direct call (no network)

Key Properties

  • No RemoteException: Cleaner method signatures
  • Pass-by-reference: Parameters passed directly (not serialized)
  • Faster: No RMI-IIOP overhead
  • Same JVM requirement: Cannot be used for remote clients

Connections

Edge Cases & Gotchas

  • Mixing local and remote: If you look up a LocalHome via JNDI from a remote client, you’ll get an error
  • ClassLoader issues: In same JVM but different ClassLoaders can still cause problems
  • Transaction propagation: Local calls propagate transactions automatically (unlike remote which may require distributed transactions)

Code Example

public interface HelloLocalHome extends javax.ejb.EJBLocalHome {
    HelloLocal create() throws javax.ejb.CreateException;
    // Note: No RemoteException!
}