Remote Access

This article explains how to access remote EJB layers in different configurations using the Orion Application Server.



1 Introduction

    The goal of this article is to explain different ways of accessing EJBs remotedly using various different configurations.

    The article requires basic knowledge of EJB and J2EE as well as Orion configuration and deployment settings.

2 Different Applications on single Server

    This section describes how to access another applications EJB layer from an application deployed at the same server.

    It involves Orion specific configuration that will lead to that the second application can utilize the classes of the first application as if they were local. It is therefore very important not to include any remote- or home-interfaces belonging to a module in the first application in the second application's modules. Such duplication could lead to ClassCastExceptions being thrown at runtime.


    Figure 1: Using parent attribute to extend applications

    This section involves the following steps:



    Throughout these steps, we will use the following terms:

    TermDescription
    Server A The Orion Application Server that will host the two applications
    a.ear The J2EE application holding an EJB-module with the EJB to access
    b.ear The J2EE application holding an Web-module containing a Servlet that wants to access the EJB in the application a.ear
    Site A The Web-site the Web-module should be bound to.
    ejb.jar The EJB-module in a.ear, containing a EJB.
    web.war The Web-module in b.ear, containing a Servlet that wants to access the EJB in the application a.ear
    Table 1: Terms and definitions used in this section

    2.1 Step 1: Deploying a.ear on Server A

      In order for an application to be accessible it must be deployed somewhere. The first thing to do is therefore to deploy a.ear on the Server A that will host the applications.

      Step-by-step instructions for deploying an application on the Orion Application Server can be found here.

    2.2 Step 2: Deploying b.ear on Server A

      As the described scenario involved two applications on the same server, the client application (b.ear) should also be deployed on Server A.

      Step-by-step instructions for deploying an application on the Orion Application Server can be found here.

      If the Console is used for deploying b.ear, make sure that a.ear is selected as parent of the application and skip step 4 below.

    2.3 Step 3: Binding web.war to Site A

      As the application b.ear holds an Web-module (refered to as web.war) this must be bound to the site (Site A) on Server A.

      Step-by-step instructions for binding a Web-module to a site on the Orion Application Server is available here.

    2.4 Step 4: Edit deployment settings

      Edit server.xml so that the deployment settings for application a.ear and b.ear to look something like the following:


      <application name="a"
      path="/orion/applications/a.ear"
      auto-start="true" />
      <application name="b"
      path="/orion/applications/b.ear"
      parent="a"
      auto-start="true" />
      Listing 1: Setting up a parent relationship between the applications

      The file server.xml is normally located in /orion/config/server.xml

      The syntax of the application tag can be found here.

    2.5 Step 5: Testing

      You should now be able to use the Servlet in web.war to access the EJBs in ejb.jar.

3 Same Application on different Servers

    This section describes how to access the EJB layer on a remote Server using deployment of the same Application on both servers but marking the EJB-module as remote on one of them.


    Figure 2: Using remote attribute to access module on other server.

    This section involves the following steps:



    Throughout these steps, we will use the following terms:

    TermDescription
    Server A The Orion Application Server that will deploy the EJB-module
    Server B The Orion Application Server that will bind the Web-module
    a.ear The J2EE application holding a EJB-module and a Web-module to access it
    Site A The Web-site the Web-module should be bound to.
    web.war The Web-module in a.ear, containing a Servlet that wants to access the EJB in the application a.ear
    ejb.jar The EJB-module in a.ear, containing an EJB.
    Table 2: Terms and definitions used in this section

    3.1 Step 1: Deploying a.ear on Server A

      In order for an application to be accessible it must be deployed somewhere. The first thing to do is therefore to deploy a.ear on the Server A that will host the applications EJB-module.

      Step-by-step instructions for deploying an application on the Orion Application Server is availalbe here.

    3.2 Step 2: Deploying a.ear on Server B

      As the described scenario involved one application deployed on two different servers, the application should now also be deployed on Server B.

      Step-by-step instructions for deploying an application on the Orion Application Server is availalbe here.

      In order for this setup to work, you need to deploy the application using the same deployment-name on both servers.

      If the Console is used to deploy a.ear on server B, make sure to mark the EJB-module as remote and skip step 5 below.

    3.3 Step 3: Configure Server A to be accessable

      In order for applications on Server B to be able to communicate with applications on Server A, Server A must accept RMI communication.

      Configure Server A to be acessible for RMI requests.

      Step-by-step instructions for RMI configuration is available here.

    3.4 Step 4: Configure Server B to access Server A

      In order for applications on Server B to be able to communicate with applications on Server A, Server B must know about Server A.

      Configure Server B to have RMI access to Server B.

      Step-by-step instructions for RMI configuration is available here.

    3.5 Step 5: Edit deployment configuration for a.ear on Server B

      Although we deployed a.ear on Server B, we will not want to use its ejb.jar locally. We must therefore edit the Orion specific deployment configuration of the application and mark the EJB-module as remote.

      Edit orion-application.xml so that it looks something like the following:


      <ejb-module
      ...
      remote="true"/>
      Listing 2: Setting the EJB-module to remote

      The syntax of the ejb-module tag can be found here.

    3.6 Step 6: Testing

      You should now be able to use the Servlet in web.war on Server B to access the EJBs in ejb.jar on Server A.

Copyright 2003 IronFlare AB