Java Persistence API (JPA) EclipseLink Sample

The EclipseLink JPA sample is designed to show how you can easily replace the default JPA provider used in WebSphere Application Server Liberty Profile with an alternate JPA provider. It contains a server definition which includes the Servlet, JDBC and JPA features. It also contains a very simple JPA application, jpaSample.war, which contains a single servlet, JPAServlet. This servlet persists a JPA entity (named "Thing") to a derby database and then retrieves the entiry from the database.

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 eclipselinkJPASample

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

Offline installation:

  1. Download the eclipselinkJPASample.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 eclipselinkJPASample.jar

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

Running The Application

To run the jpaApp application:

  1. Start the eclipselinkJPASample server by running the command below from the bin directory in the Liberty profile installation:
    server run eclipselinkJPASample
  2. Confirm the application started by looking for the following message in the log:
    CWWKZ0001I: Application jpaApp started in XX.XX seconds.
  3. In your browser, enter the URL for the application: http://localhost:9142/jpaApp/JPAServlet (where port 9142 assumes the httpEndpoint provided in the sample server.xml has not been modified).
  4. In your browser, you should see the message
    Hello JPA World
    followed by information about the entity being persisted to and retrieved from the database.

Notes

The jpaApp.war file contains the source and binaries for the application, and can be used to import it to Eclipse.

Sample Structure

  • wlp
    • usr
      • servers
        • eclipselinkJPASample
          • Copyright.txt
          • apps
            • jpaApp.war
          • lafiles
            • LA_en
            • LI_en
          • readme.html
          • server.xml
      • shared
        • resources
          • EclipseLinkJpaSampleDerbyLibs
            • derby-10.10.1.1.jar
          • EclipseLinkLibs
            • eclipselink-2.5.2.jar