The following sample contains a server definition which contains a very simple JPA application consisting of a single servlet and a JPA servlet.
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 220.127.116.11 and later.
To run the jpaApp application:
- Extract the sample into the Liberty installation by running the command below from the root of your server installation:
java -jar jpaSample.jar
- Start the jpaSample server by running the command below from the
bindirectory in the Liberty profile installation:
server run jpaSample
- Confirm the application started by looking for the following message in the log:
CWWKZ0001I: Application jpaApp started in XX.XX seconds.
- 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).
- 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.
jpaApp.war file contains the source and binaries for the application, and can be used to import it to Eclipse.
- - wlp
- - usr
- - servers
- - jpaSample
- - dropins
- - jpaApp.war
- - server.xml
- - readme.html
- - Copyright.txt