Enterprise Java Beans (EJB) Sample

This sample demonstrates injection of an EJB into a servlet. The application consists of a servlet and stateless session bean. The servlet uses annotations to inject the stateless session bean, and then performs a call on the hello method of the bean.

This sample can be installed onto runtime versions 8.5.5.0 and later.

Installation Instructions

Online installation (requires 8.5.5.6 or later):

  1. Install the sample by running the command below from the bin directory of your server installation:
    installUtility install EJBSample

Any missing features required by the server will be installed for you.

Offline installation:

  1. Download the EJBSample.jar using the download button at the top of the page and place it in the root of your server installation.
  2. Extract the sample into the Liberty installation by running the command below from the root of your server installation:
    java -jar EJBSample.jar

Any missing features required by the server will need to be installed separately.

Running The Application

To run the EJBSample application:

  1. Start the EJBSample server by running the command below from the bin directory in the Liberty profile installation:
    server run EJBSample
  2. Confirm the application started by looking for the following message in the log:
    CWWKZ0001I: Application EJBSample started in XX.XX seconds.
  3. In your browser, enter the URL for the application: http://localhost:9132/EJBApp/sampleServlet (where 9132 is the default HTTP endpoint).
  4. In your browser, you should see the message "Hello EJB World".

Notes

  • The application is automatically installed because it is located in the server dropins directory. Any number of applications can be installed from this location.
  • Source code for the application can be found in the application's EAR file, located in the EJBSample/dropins folder.

Sample Structure

  • wlp
    • usr
      • servers
        • EJBSample
          • Copyright.txt
          • dropins
            • EJBApp.ear
          • readme.html
          • server.xml