Java Persistence API (JPA) Sample

Description

The JPA sample contains a server definition which includes the Servlet, JDBC and JPA features. It also contains a very simple JPA application, jpaApp.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.0.0 and later.

Instructions

To run the jpaApp application:

  1. Extract the sample into the Liberty installation by running the command below from the root of your server installation:
    java -jar jpaSample.jar
  2. Start the jpaSample server by running the command below from the bin directory in the Liberty profile installation:
    server run jpaSample
  3. Confirm the application started by looking for the following message in the log:
    CWWKZ0001I: Application jpaApp started in XX.XX seconds.
  4. In your browser, enter the URL for the application: http://localhost:9119/jpaApp/JPAServlet (where port 9119 assumes the httpEndpoint provided in the sample server.xml has not been modified).
  5. 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
        • jpaSample
          • Copyright.txt
          • dropins
            • jpaApp.war
          • lafiles
            • LA_en
            • LI_en
          • readme.html
          • server.xml
      • shared
        • resources
          • JpaSampleDerbyLibs
            • derby-10.10.1.1.jar

External Dependencies

The table below shows the dependencies that are required for: Derby pre-requisite libraries.

Target install path Source URL
shared/resources/JpaSampleDerbyLibs/derby-10.10.1.1.jar http://repo1.maven.org/maven2/org/apache/derby/derby/10.10.1.1/derby-10.10.1.1.jar

Support Information

For further information and resources for developers using IBM WebSphere Application Server, please visit wasdev.net.

Licensed Materials - Property of IBM © Copyright IBM Corp. 1997, 2013. All Rights Reserved. IBM, and the IBM logo are trademarks or registered trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at Copyright and trademark information.