Skip to content

EJB remote service lookup pattern

The EJB remote service lookup pattern refers to the specific configuration and code structure required to access an Enterprise JavaBean (EJB) deployed on a remote server, typically within a Java EE application server environment like WebLogic.

JNDI Configuration

To establish a connection with a remote EJB, the client must create an InitialContext object configured with specific Java Naming and Directory Interface (JNDI) properties.^[weblogic-ejb.md]

The configuration generally requires the following properties:

  • INITIAL_CONTEXT_FACTORY: Set to the factory class specific to the application server (e.g., weblogic.jndi.WLInitialContextFactory for WebLogic).^[weblogic-ejb.md]
  • PROVIDER_URL: The address of the remote server (e.g., t3://localhost:8080).^[weblogic-ejb.md]
  • Security Credentials: The SECURITY_PRINCIPAL (username) and SECURITY_CREDENTIALS (password) for authentication.^[weblogic-ejb.md]

Service Lookup

Once the InitialContext is initialized, the remote service is retrieved via a lookup string.^[weblogic-ejb.md] This string typically follows the format mapped-name#fully-qualified-interface-name.^[weblogic-ejb.md]

For example, to look up a service, one might use: ctx.lookup("bpm/ejb/WorkflowEngineService#core.bpm.service.workflow.engine.WorkflowEngineServiceRemote")^[weblogic-ejb.md]

Usage

After performing the lookup, the returned Object is cast to the remote service interface, allowing the client to invoke business methods exposed by the EJB.^[weblogic-ejb.md]

Sources

^[weblogic-ejb.md]

  • [[EJB]]
  • JNDI
  • [[WebLogic]]
  • [[RMI]]