Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/Packaging an Application"

(Packaging Java Applications)
Line 20: Line 20:
  
 
==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 figure shows.
+
For non-Java EE Java applications, it is common to package the application in a single JAR file, as this example shows.
  
 
+
<span id="Example 9-1"></span>
<span id="Figure 9-1"></span>
+
 
'''''Packaging a non-Java EE Java Application'''''
 
'''''Packaging a non-Java EE Java Application'''''
 
+
  domain_module.jar
[[Image:pkgjava.gif|Packaging a non-Java EE Java Application]]<br /><br />
+
      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:
Line 36: Line 40:
  
 
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 JavaServer Pages and Servlet Applications==
 
==Packaging JavaServer Pages and Servlet Applications==

Revision as of 04:04, 30 May 2008

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.


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:


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 figure shows.


Packaging a Java EE JSP or Servlet Application Without EJB

Packaging a Java EE JSP or Servlet Application Without EJB

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.




Copyright Statement

Back to the top