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-2.1.thinclient_9.0.jar
stand-alone Java archive (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.
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 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.
- When you run your stand-alone application, specify the JAR files in your class path when
starting your 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