Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop EJB applications > Assembling applications that use the Java Persistence API


Assembling JPA applications for a Java SE environment

You have developed and configured the applications to work with the Java Persistence API (JPA). Now package the JPA applications for the environment.

For this task, you must specify the com.ibm.ws.jpa.thinclient_8.0.0.jar stand-alone Java archive (JAR) file in your class path. This stand-alone JAR file is available from the client and server installation images. The location of this file on the client installation image is ${ APP_CLIENT_ROOT}/runtimes/com.ibm.ws.jpa.thinclient_8.0.0.jar. The location of this file on the server installation image is ${ WAS_HOME}/runtimes/com.ibm.ws.jpa.thinclient_8.0.0.jar.


Procedure

  1. Package the application.

    Package the persistence units in separate JAR files to make them more accessible and reusable. If you package the persistence units this way, they can be tested outside the container both with and without the occurrence of database persistence. The persistence units can be included in stand-alone applications or they can be packaged into EAR files as persistence archive files. If you package the persistence unit into a persistence archive file, all of the application components must be able to access the persistence archive. The application that uses the persistence units must declare a dependency on the persistence archive using the MANIFEST.MF Class-Path: declaration.

    The Criteria Metamodel class files that are generated by the Annotation Processor when you developed your JPA application, must be included in the JAR file in the same location as the entity class files.

    If you are using IBM Optim PureQuery Run time, add the persistence_unit_name.pdqxml files to the JPA application JAR file. The files are located in same META-INF directory where your persistence.xml file is located. These persistence files were created during the development task, Developing JPA applications for a Java SE environment. To package the application use the following command:

    jar -cvf ${jar_Name} ${entity_Path}
    
    where ${jar_Name} represents the name of the JAR file to create, and ${entityPath} represents the root location where the entities reside, which is where you compiled them. Make sure that your ${entity_Path} also contains the META-INF/persistence.xml file.

  2. When you run your stand-alone application, specify the JAR files in your class path when starting the application. The JPA runtime starts the stand-alone JAR file, com.ibm.ws.jpa.thinclient_8.0.0.jar. For example, use the following Java call to run the com.xyz.Main stand-alone application:
    java -cp /your/directory/${jar_Name}
    -javaagent:${
    APP_CLIENT_ROOT}/runtimes/com.ibm.ws.jpa.thinclient_8.0.0.jarcom.xyz.Main
    


What to do next

For more information about any of the commands, classes or other OpenJPA information, refer to the Apache OpenJPA User Guide.
Develop JPA 2.x applications for a Java SE environment
Task overview: Storing and retrieving persistent data with the JPA API
Apache OpenJPA User Guide

+

Search Tips   |   Advanced Search