EJB 3.0 Counter sample setup

This sample contains an EJB 3.0 project and a dynamic Web project to display a simple counter program.
  1. Install WebSphere® Application Server version 7.0.
  2. Import the sample into your workspace.
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:
  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).
  3. Make sure that WebSphere Application Server version 7.0 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 v.7.0.
    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.
      Restriction: When running the EJBCounterJSF.jsp file, you must select WebSphere Application Server v.7.0; if you try to run the EJBCounterJSF.jsp on WebSphere Application server v.6.1, you will get an error: The server does not support version 2.5 of the J2EE Web module specification.
    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