Job Bank EJB Binding Sample

Table of Contents

Overview

Affiliates Icon

This sample shows the SCA stateless session bean binding support. The stateless session bean binding is a protocol binding which provides the ability to integrate SCA with EJB based services.

  1. The Reference binding enables SCA components to invoke stateless session beans
  2. The Service binding exposes an SCA service as a stateless session bean for consumption by J2EE applications

This sample shows how to invoke a SCA component using JEE programming model and how a component with an EJB reference binding can invoke a stateless EJB which is in JobbankTargetEJBApp.

The non-SCA, J2EE client packaged within JobbankClientApp invokes the 'Company' service which is exposed over the EJB binding. This Company service is invoked as a normal EJB, then, from the perspective of the client application, without awareness that the client is invoking an SCA service exposed over the remote EJB service binding. The Company component, in turn, contains a reference to a ResumeBank EJB, which it invokes using the simple SCA programming model. This reference is configured using the EJB reference binding to point to a Stateless Session bean packaged within the JobbankTargetEJBApp application. The simple SCA programming model allows the Company component to invoke the ResumeBank EJB service using a simple POJO-like invocation without having to use JEE client APIs.

Architectural Diagram

Artifacts involved:

  1. jobbankejb.jar - This contains SCA component "Company". This component exposes its service as a stateless EJB through ejb binding service and access external EJB through ejb binding reference to post a resume.
  2. JobbankTargetEJBApp.ear - External EJB which is accessed by the component
  3. JobbankClientApp.ear - J2EE client. JobbankClientApp.ear is a pure J2EE client app. This app shouldn't be installed onto Websphere through the administrative console. This client runs from the command line.

Prerequisites

  • This sample application requires that you have the WebSphere Application Server installed.
  • NOTE: This document will reference the location that these samples have been extracted to as <SCA_SAMPLE_HOME>.

Limitations

There are no noteable design limitations specific to this sample.

Build

Build Icon

Compile and build the installable artifacts using the provided ANT build script.

  1. Find out the bootstrap port of the application server. (See the WebSphere Application Server infocenter for more information on how to determine the port of the application server)
  2. Open the <SCA_SAMPLE_HOME>\jobbankejb\src\main\resources\META-INF\sca-deployables\default.composite file. Look for "uri" attribute in <binding.ejb ..> under <reference ..> element. Change the hostname and port number as per your bootstrap host and bootstrap port in uri="corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/com/app/resumebank/ResumeBankHome" ( Note that 2809 as in the default.composite file is the default for the application server)
  3. Open a command window and change to the <SCA_SAMPLE_HOME>\jobbankejb directory.
  4. Issue the following command to build the artifacts: {WAS_HOME}\profiles\{PROFILE_NAME}\bin\ws_ant
  5. Example command: C:\WebSphere\AppServer\profiles\AppSrv01\bin\ws_ant
  6. Verify that the build completes without error and the following atrifacts have been created in <SCA_SAMPLE_HOME>\jobbankejb\target

    • JobbankClientApp.ear
    • jobbankejb.jar
    • JobbankTargetEJBApp.ear

Install

Install Icon

Automated install: To quickly and easily install this sample and bypass the manual steps following, you can use the automated install. Run the following command from the Job Bank sample directory:

<WAS_HOME>\profiles\<PROFILE_NAME>\bin\ws_ant install
<WAS_HOME>\profiles\<PROFILE_NAME>\bin\ws_ant start
NOTE: If the default port number for SOAP is not 8880 for your application server profile, please update the SOAP port number value in <SCA_SAMPLE_HOME>\common\manage-app.xml to match your profile.

SCA Composite

  1. Start the WebSphere Application Server if it is not already started.
    1. Open a command window and issue the following command:

      cd <WAS_HOME>\profiles\<PROFILE_NAME>\bin

      Example command:

      cd C:\WebSphere\AppServer\profiles\AppSrv01\bin
    2. Issue the startServer command

      startServer server1
  2. Use the Administrative Console to import jobbankejb.jar
    1. Open a Log into the Administrative Console by navigating to http://localhost:9060/admin in a Web browser.
    2. From the left navigation panel of the Administrative console, expand Applications then Application Types and select Assets.
    3. Press the Import button, then browse to <SCA_SAMPLE_HOME>\jobbankejb\target\ and select the jobbankejb.jar file. Click Next using all the default settings until you reach the summary page and click Finish.
    4. Click the Save link at the top of the screen.
  3. Use the Administrative Console to create the Business-level Applications that will run the SCA composites.
    1. From the left navigation panel of the Administrative console, expand Applications and select Application Types and then Business-level Applications and click on New.
    2. Fill in jobbankejb for name and click Apply.
    3. Click the Save link at the top of the screen.
    4. Go to Applications and select Applicaton Types and then Business-level Applications. Then click on jobbankejb.
    5. Under Deployed Assets click on Add and choose Add Asset. Select jobbankejb.jar and click Continue.
    6. Click Next until the last panel and then click Finish.
    7. Click the Save link at the top of the screen, and return to Applications and select Application Types and then Business-level Applications. Select the jobbankejb checkbox and click on Start.

Target EJB

Use the Administrative Console to install target EJB application.

  1. From the left navigation panel of the Administrative console, expand Applications and then select New Application and select New Enterprise Application.
  2. On the install panel, specify the Local file system option and enter the Full path or use the browse button to select the JobbankTargetEJBApp.ear file located in the <SCA_SAMPLE_HOME>\jobbankejb\target\ directory. Click Next.
  3. For the remaining install panels, select the defaults by clicking Next until you reach the final panel. Click Finish to complete the installation of the sample application.
  4. The application will appear in the list of applications and its initial status will be stopped" (Status of Red). Expand Applications then Application Types and select WebSphere enterprise applications. Check the box next to JobbankTargetEJBApp and press Start.

Running

Run Icon
  1. Open a command window. cd WAS_HOME\bin
  2. launchClient.bat <SCA_SAMPLE_HOME>\jobbankejb\target\JobBankClientApp.ear -CCclasspath=WAS_HOME\profiles\YOUR_PROFILE_NAME\installedApps\YOUR_CELLNAME\JobBankApp.ear\CompanyComponent_Company.jar -CCBootstrapHost=localhost -CCBootstrapPort=2809

    where

    1. WAS_HOME = Websphere home directory
    2. YOUR_PROFILE_NAME = your profile name
    3. YOUR_CELLNAME = Your Cell name under "installedApps" under your profile
    4. -CCBootstrapHost = hostname
    5. -CCBootstrapPort= Bootstrap port for your Websphere instance
    6. These settings are needed to bootstrap the WAS J2EE client container.
  3. You should see the result printed on the console and also in your SystemOut.log. It will look something like:

    INVOKING SCA COMPONENT THROUGH COMPONENT SERVICE WITH EJB BINDING
    Getting company info for Company: ACME Corp
    Result from SCA Component. Company type: Software firm
    INVOKING COMPONENT SERVICE->COMPONENT->COMPONENT REFERENCE->EXTERNAL EJB
    Posting resume: John Doe
    Confirmation number: 1559740348

Uninstall

Uninstall Icon

Automated uninstall: To quickly and easily uninstall this sample and bypass the manual steps following, you can use the automated uninstall. Run the following command from the Job Bank EJB sample directory:

<WAS_HOME>\profiles\<PROFILE_NAME>\bin\ws_ant uninstall

Manual uninstall

  1. From the left navigation panel of the Administrative console, expand Applications then Application Types and select Business-level Applications. You should see one Job Bank related BLA on this page, jobbankejb. Click on jobbankejb. Under Deployed assets check all the non Shared Library assets and click delete. These assets are usually marked as "asset" under the Type column.
  2. After the non shared library assets are removed, select all the shared library assets that are left under Deployed assets and delete them. Once all the assets are removed, click on the Save link at the top of the screen.
  3. Expand Applications then Application Types and select Business-level Applications. Select jobbankejb and click on delete and then click the Save link at the top of the screen.
  4. Next you will need to uninstall the Job Bank EARs. Expand Applications then Application Types and select WebSphere Enterprise Applications. Select JobBankClientApp and JobbankTargetEJBApp and click on Uninstall. After the enterprise applications have been removed click on the Save link at the top of the screen.

User's Guide

When you run the sample you should see output that looks like this printed on the console and also in your SystemOut.log:

INVOKING SCA COMPONENT THROUGH COMPONENT SERVICE WITH EJB BINDING
Getting company info for Company: ACME Corp
Result from SCA Component. Company type: Software firm
INVOKING COMPONENT SERVICE->COMPONENT->COMPONENT REFERENCE->EXTERNAL EJB
Posting resume: John Doe
Confirmation number: 1559740348