Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/Packaging an Application"
m (→How to Create the EclipseLink Domain JAR) |
m |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | [[Image:Elug draft icon.png]] '''For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/ ''' | ||
+ | |||
+ | ---- | ||
+ | |||
<div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__ | <div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__ | ||
[[Special:Whatlinkshere/Packaging a EclipseLink Application (ELUG)|Related Topics]]</div>How you package the components of your application depends on the type of application and how you plan to deploy it. | [[Special:Whatlinkshere/Packaging a EclipseLink Application (ELUG)|Related Topics]]</div>How you package the components of your application depends on the type of application and how you plan to deploy it. | ||
This section describes EclipseLink-specific details applicable to the common packaging strategies used for various types of applications. | This section describes EclipseLink-specific details applicable to the common packaging strategies used for various types of applications. | ||
− | |||
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups" | {| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups" | ||
Line 20: | Line 23: | ||
==Packaging Java Applications== | ==Packaging Java Applications== | ||
− | For non-Java EE Java applications, it is common to package the application in a single JAR file, as this | + | For non-Java EE Java applications, it is common to package the application in a single JAR file, as this example shows. |
− | <span id=" | + | <span id="Example 9-1"></span> |
'''''Packaging a non-Java EE Java Application''''' | '''''Packaging a non-Java EE Java Application''''' | ||
− | + | domain_module.jar | |
− | + | Java classes that represent the objects mapped | |
+ | project.xml | ||
+ | session.xml | ||
+ | META-INF | ||
+ | Manifest.mf | ||
+ | <br /><br /> | ||
This JAR contains the EclipseLink files and domain objects required by the application, including the following: | This JAR contains the EclipseLink files and domain objects required by the application, including the following: | ||
− | * [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)|sessions.xml File]]; | + | * [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)#sessions.xml File|sessions.xml File]]; |
− | * [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)|project.xml File]] (or the compiled <tt>Project</tt> class file if you are not using XML files for deployment); | + | * [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)#project.xml File|project.xml File]] (or the compiled <tt>Project</tt> class file if you are not using XML files for deployment); |
* The mapped classes required by the application, in a fully-resolved directory structure. | * The mapped classes required by the application, in a fully-resolved directory structure. | ||
Line 38: | Line 46: | ||
==Packaging JavaServer Pages and Servlet Applications== | ==Packaging JavaServer Pages and Servlet Applications== | ||
− | For simple Java EE applications without EJB, it is common to package the application in an Enterprise Archive (EAR) file made up of various Java EE application component archives, as this | + | For simple Java EE applications without EJB, it is common to package the application in an Enterprise Archive (EAR) file made up of various Java EE application component archives, as this example shows. |
− | <span id=" | + | <span id="Example 9-2"></span> |
'''''Packaging a Java EE JSP or Servlet Application Without EJB''''' | '''''Packaging a Java EE JSP or Servlet Application Without EJB''''' | ||
− | + | appname.ear | |
+ | META-INF | ||
+ | application.xml | ||
+ | orion-application.xml | ||
+ | domain_module.jar | ||
+ | Java classes that represent the object mapped | ||
+ | project.xml | ||
+ | session.xm | ||
+ | META-INF | ||
+ | Manifest.mf | ||
+ | web_module.war | ||
+ | html pages, JSP’s, etc. | ||
+ | META-INF | ||
+ | web.xml | ||
+ | orion-web.xml | ||
+ | classes | ||
+ | servlet classes | ||
+ | lib | ||
+ | client_module.jar | ||
+ | Client classes | ||
+ | META-INF | ||
+ | application-client.xml | ||
+ | orion-application-client.xml<br /><br /> | ||
The component archives with EclipseLink dependencies include EclipseLink domain JAR (see [[#How to Create the EclipseLink Domain JAR|How to Create the EclipseLink Domain JAR]]). | The component archives with EclipseLink dependencies include EclipseLink domain JAR (see [[#How to Create the EclipseLink Domain JAR|How to Create the EclipseLink Domain JAR]]). | ||
Line 53: | Line 83: | ||
The domain JAR contains the EclipseLink files and domain objects required by the application, including the following: | The domain JAR contains the EclipseLink files and domain objects required by the application, including the following: | ||
− | * [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)|sessions.xml File]]; | + | * [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)#sessions.xml File|sessions.xml File]]; |
− | * [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)|project.xml File]] (or the compiled <tt>Project</tt> class file, if you are not using XML files for deployment); | + | * [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)#project.xml File|project.xml File]] (or the compiled <tt>Project</tt> class file, if you are not using XML files for deployment); |
* The mapped classes required by the application, in a fully resolved directory structure. | * The mapped classes required by the application, in a fully resolved directory structure. | ||
Line 68: | Line 98: | ||
===How to Package an EJB 3.0 Session Bean Application=== | ===How to Package an EJB 3.0 Session Bean Application=== | ||
For information on how to package an EJB 3.0 session bean application, see [[Packaging and Deploying EclipseLink JPA Applications (ELUG)|Packaging a EclipseLink JPA Application]]. | For information on how to package an EJB 3.0 session bean application, see [[Packaging and Deploying EclipseLink JPA Applications (ELUG)|Packaging a EclipseLink JPA Application]]. | ||
+ | |||
+ | |||
===How to Create the EclipseLink Domain JAR=== | ===How to Create the EclipseLink Domain JAR=== | ||
The domain JAR contains the EclipseLink files and domain objects required by the application, including the following: | The domain JAR contains the EclipseLink files and domain objects required by the application, including the following: | ||
− | * <tt>sessions.xml</tt> (see [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)|sessions.xml File]]); | + | * <tt>sessions.xml</tt> (see [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)#sessions.xml File|sessions.xml File]]); |
− | * <tt>project.xml</tt> (see [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)|project.xml File]]) (or the compiled <tt>Project.class</tt> file if you are not using XML files for deployment); | + | * <tt>project.xml</tt> (see [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)#project.xml File|project.xml File]]) (or the compiled <tt>Project.class</tt> file if you are not using XML files for deployment); |
* The mapped classes required by the application, in a fully-resolved directory structure. | * The mapped classes required by the application, in a fully-resolved directory structure. | ||
When you create the JAR file, the JAR building utility automatically creates a directory structure within the JAR. Ensure that the <tt>sessions.xml</tt> file and the <tt>project.xml</tt> file (or <tt>project.class</tt> file) appear at the root of the JAR file. Also ensure that the class directory structure starts at the root of the JAR. | When you create the JAR file, the JAR building utility automatically creates a directory structure within the JAR. Ensure that the <tt>sessions.xml</tt> file and the <tt>project.xml</tt> file (or <tt>project.class</tt> file) appear at the root of the JAR file. Also ensure that the class directory structure starts at the root of the JAR. | ||
− | If you do not store the <tt>project.xml</tt> or <tt>sessions.xml</tt> files at the root of the JAR file, see [#Packaging with EclipseLink Metadata File Resource Paths|Packaging with EclipseLink Metadata File Resource Paths]. | + | If you do not store the <tt>project.xml</tt> or <tt>sessions.xml</tt> files at the root of the JAR file, see [[#Packaging with EclipseLink Metadata File Resource Paths|Packaging with EclipseLink Metadata File Resource Paths]]. |
+ | |||
==Packaging JPA Applications== | ==Packaging JPA Applications== | ||
See [[Packaging and Deploying EclipseLink JPA Applications (ELUG)|Packaging a EclipseLink JPA Application]] for information on how to package your JPA application. | See [[Packaging and Deploying EclipseLink JPA Applications (ELUG)|Packaging a EclipseLink JPA Application]] for information on how to package your JPA application. | ||
+ | |||
==Packaging a POJO Application for Weaving== | ==Packaging a POJO Application for Weaving== | ||
Line 87: | Line 121: | ||
For more information on weaving, see [[Introduction to EclipseLink%20Application%20Development%20(ELUG)|To Package a POJO Application for Weaving]]. | For more information on weaving, see [[Introduction to EclipseLink%20Application%20Development%20(ELUG)|To Package a POJO Application for Weaving]]. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Packaging with EclipseLink Metadata File Resource Paths== | ==Packaging with EclipseLink Metadata File Resource Paths== | ||
Line 125: | Line 134: | ||
To acquire the session, use the following: | To acquire the session, use the following: | ||
+ | <source lang="java"> | ||
SessionManager.getManager().getSession( | SessionManager.getManager().getSession( | ||
new XMLSessionConfigLoader("myapp/ordersys/persist/sessions.xml"), | new XMLSessionConfigLoader("myapp/ordersys/persist/sessions.xml"), | ||
Line 130: | Line 140: | ||
getClass().getClassLoader() | getClass().getClassLoader() | ||
); | ); | ||
− | + | </source> | |
For more information about acquiring sessions at run time, see [[Acquiring%20and%20Using%20Sessions%20at%20Run%20Time%20(ELUG)|Acquiring a Session from the Session Manager]]. | For more information about acquiring sessions at run time, see [[Acquiring%20and%20Using%20Sessions%20at%20Run%20Time%20(ELUG)|Acquiring a Session from the Session Manager]]. | ||
+ | |||
+ | |||
+ | ==Packaging Directories with a Dot (.)== | ||
+ | When packaging applications, avoid using a dot (.) in a directory in a WAR file as this may cause deployment to fail. For example, if your WAR includes: | ||
+ | |||
+ | <tt> | ||
+ | WEB-INF/classes/.foo/jsp_servlet/bar.jspx | ||
+ | </tt> | ||
+ | |||
+ | deployment may fail during persistence unit processing because the application could not find a class named <b>.foo.jsp_servlet.bar.jspx</b>. | ||
Line 141: | Line 161: | ||
[[Category: EclipseLink User's Guide]] | [[Category: EclipseLink User's Guide]] | ||
− | [[Category: | + | [[Category: Release 1]] |
− | [[Category: | + | [[Category: Task]] |
Latest revision as of 11:21, 18 July 2012
For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/
Contents
This section describes EclipseLink-specific details applicable to the common packaging strategies used for various types of applications.
Note: If you are using EJB 3.0, you may be using annotations instead of some deployment files. Include deployment descriptors to override annotations or specify options not supported by annotations. |
For more information, see the following:
- Integrating EclipseLink with an Application Server
- Creating EclipseLink Files for Deployment
- Deploying a EclipseLink Application
Packaging Java Applications
For non-Java EE Java applications, it is common to package the application in a single JAR file, as this example shows.
Packaging a non-Java EE Java Application
domain_module.jar Java classes that represent the objects mapped project.xml session.xml META-INF Manifest.mf
This JAR contains the EclipseLink files and domain objects required by the application, including the following:
- sessions.xml File;
- project.xml File (or the compiled Project class file if you are not using XML files for deployment);
- The mapped classes required by the application, in a fully-resolved directory structure.
When you create the JAR file, the JAR building utility automatically creates a directory structure within the JAR. Ensure that the sessions.xml file and the project.xml file (or project class file) appear at the root of the JAR file. Ensure that the class directory structure starts at the root of the JAR.
If you do not store the project.xml or sessions.xml files at the root of the JAR file, see Packaging with EclipseLink Metadata File Resource Paths.
Packaging JavaServer Pages and Servlet Applications
For simple Java EE applications without EJB, it is common to package the application in an Enterprise Archive (EAR) file made up of various Java EE application component archives, as this example shows.
Packaging a Java EE JSP or Servlet Application Without EJB
appname.ear META-INF application.xml orion-application.xml domain_module.jar Java classes that represent the object mapped project.xml session.xm META-INF Manifest.mf web_module.war html pages, JSP’s, etc. META-INF web.xml orion-web.xml classes servlet classes lib client_module.jar Client classes META-INF application-client.xml orion-application-client.xml
The component archives with EclipseLink dependencies include EclipseLink domain JAR (see How to Create the EclipseLink Domain JAR).
How to Create the EclipseLink Domain JAR
The domain JAR contains the EclipseLink files and domain objects required by the application, including the following:
- sessions.xml File;
- project.xml File (or the compiled Project class file, if you are not using XML files for deployment);
- The mapped classes required by the application, in a fully resolved directory structure.
When you create the JAR file, the JAR building utility automatically creates a directory structure within the JAR. Ensure that the sessions.xml file and the project.xml file (or project.class file) appear at the root of the JAR file. Also ensure that the class directory structure starts at the root of the JAR.
If you do not store the project.xml or sessions.xml files at the root of the JAR file, see Packaging with EclipseLink Metadata File Resource Paths.
Packaging Session Bean Applications
This section contains information on How to Package an EJB 3.0 Session Bean Application.
How to Package an EJB 3.0 Session Bean Application
For information on how to package an EJB 3.0 session bean application, see Packaging a EclipseLink JPA Application.
How to Create the EclipseLink Domain JAR
The domain JAR contains the EclipseLink files and domain objects required by the application, including the following:
- sessions.xml (see sessions.xml File);
- project.xml (see project.xml File) (or the compiled Project.class file if you are not using XML files for deployment);
- The mapped classes required by the application, in a fully-resolved directory structure.
When you create the JAR file, the JAR building utility automatically creates a directory structure within the JAR. Ensure that the sessions.xml file and the project.xml file (or project.class file) appear at the root of the JAR file. Also ensure that the class directory structure starts at the root of the JAR.
If you do not store the project.xml or sessions.xml files at the root of the JAR file, see Packaging with EclipseLink Metadata File Resource Paths.
Packaging JPA Applications
See Packaging a EclipseLink JPA Application for information on how to package your JPA application.
Packaging a POJO Application for Weaving
To package a POJO application for weaving, you create a JAR that contains a sessions.xml file and a persistence.xml file.
For more information on weaving, see To Package a POJO Application for Weaving.
Packaging with EclipseLink Metadata File Resource Paths
If you do not store the project.xml or sessions.xml files at the root of the JAR file, then you must provide the full resource path to the files when accessing them. Ensure that you use "/" in resources paths, not "\". Using "\" will not work in Java.
For example, in the jar element, reference the project.xml and sessions.xml files as follows:
<jar>/myapp/ordersys/persist/sessions.xml <jar>/myapp/ordersys/persist/project.xml
In the sessions.xml file, reference the project.xml as follows:
myapp/ordersys/persist/project.xml
To acquire the session, use the following:
SessionManager.getManager().getSession( new XMLSessionConfigLoader("myapp/ordersys/persist/sessions.xml"), "OrdersysSession", getClass().getClassLoader() );
For more information about acquiring sessions at run time, see Acquiring a Session from the Session Manager.
Packaging Directories with a Dot (.)
When packaging applications, avoid using a dot (.) in a directory in a WAR file as this may cause deployment to fail. For example, if your WAR includes:
WEB-INF/classes/.foo/jsp_servlet/bar.jspx
deployment may fail during persistence unit processing because the application could not find a class named .foo.jsp_servlet.bar.jspx.