+

Search Tips   |   Advanced Search

Assembling JPA applications for a Java SE environment

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

For this task, specify the com.ibm.ws.jpa-2.1.thinclient_9.0.jar stand-alone JAR file for JPA 2.1 applications, or the com.ibm.ws.jpa-2.0.thinclient_9.0.jar file in your class path. This stand-alone JAR file is available from the client and server installation images. The location of these .jar files on the client installation image is in the ${ app_client_root}/runtimes/ directory. The location of these files on the server installation image is in the ${app_server_root}/runtimes/ diretory.


Tasks

  1. Package the application.

    Package the persistence units in separate JAR files to make them more accessible and reusable. If we 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 we 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 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 we are using WSJPA and 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 we run your stand-alone application, specify the JAR files in your class path when starting the application. The JPA runtime starts one of the stand-alone JAR files, com.ibm.ws.jpa-2.1.thinclient_9.0.jar or com.ibm.ws.jpa-2.0.thinclient_9.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-2.1.thinclient_9.0.jar com.xyz.Main 
    

  • Developing JPA 2.x applications for a Java SE environment
  • Task overview: Store and retrieve persistent data with the JPA API