You have developed and configured your applications to
work with the Java Persistence
API (JPA). Now you must package the JPA applications for your environment.
About this task
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 ${app_server_root}/runtimes/com.ibm.ws.jpa.thinclient_8.0.0.jar.
Procedure
- Package the application.
Note: 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.
Note: 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.
- When you run your stand-alone application, specify the
JAR files in your class path when starting your 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.