EJB 3.0 Counter sample setup

This sample contains an EJB 3.0 project and a web project to display a simple counter program.

Before you begin

  1. Install WebSphere® Application Server V7.0. or V8.0, or V8.5.
  2. Import the EJB 3.0 sample

About this task

When the import is complete, you see the following projects in the Enterprise Explorer view:

Projects in the Enterprise Explorer view

To run the sample and test it on the server, follow these steps:

Procedure

  1. Create the Derby database. Expand the EJBCounterDB project.
  2. Double click the EJB3SampleDB.zip file.
    1. Windows icon
      : Extract the database into your /derby/databases folder of your WebSphere Application Server install folder:
    2. Linux icon
      : Extract the database into your /derby/databases folder of your WebSphere Application Server install folder.
      • Give your non-root user access to the databases directory. (The easiest way is to give everyone access: chmod ugo+x databases.
      • Give your non-root user write-access to the unzipped database. (The easiest way is to unzip as the non-root user, which will work provided the user has access to the databases directory).
      Important: Depending on the type of WebSphere Application Server, the default location of your /derby/databases may differ. For information about default installation directories, see Creating a WebSphere Application Server.
  3. Make sure that WebSphere Application Server version V7.0, V8.0, or V8.5 is available:
    1. Open the Servers view by selecting Window > Show View > Servers.
    2. Define a new server by right-clicking the Servers view and selecting New > Server. Follow the instructions in the New Server wizard, ensuring that you select the WebSphere Application Server V7.0. or V8.0,, or V8.5.
    3. On the Add and Remove Projects page, select EJBCounterEAR, and click Add:
      Add and Remove Projects page
    4. Click Finish.
  4. Deploy and run the sample application:
    1. In the Enterprise Explorer, expand the EJBCounterWeb project and expand the WebContent node. Right-click the EJBCount.jsp file, and selectRun as > Run on Server. When running the EJBCounterJSF.jsp file, select WebSphere Application Server V7.0, V8.0, or V8.5.
    2. In a Web browser, the Counter application opens.

      EJBCount.jsp

    3. On the EJB 3.0 and JPA 1.0 Counter Sample page, click the Increment button to increase the displayed count by one.

      Increment the JSP by 1.

    4. If you close the application, and rerun it, the count will continue from the last incremented number, because the number is persisted within the database.

Feedback