Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3)
B14428-02
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

26 Configuring Deployment Descriptor Files

This chapter describes how to configure the various deployment descriptor files an OC4J application may use, including:

For more information, see "Understanding EJB Deployment Descriptor Files".

Configuring the ejb-jar.xml File

This section describes:

For more information, see "What is the ejb-jar.xml File?".

Creating ejb-jar.xml During Migration

For EJB 2.1 only, you can automatically generate the ejb-jar.xml file during migration (see "Migrating to the TopLink Persistence Manager"). After generation, you can use the TopLink Workbench to customize and re-export this file (see "Using TopLink Workbench").

Creating the ejb-jar.xml File at Deployment Time

When you deploy an EJB 3.0 application with one or more annotations, OC4J will write its in-memory ejb-jar.xml file to the same location as the orion-ejb-jar.xml file in the deployment directory: <ORACLE_HOME>/j2ee/home/application-deployments/my_application/META-INF.

This ejb-jar.xml file represents configuration obtained from both annotations and a deployed ejb-jar.xml file (if present).

Creating ejb-jar.xml with JDeveloper

You can use JDeveloper to generate and update the ejb-jar.xml file.

For more information, see "Using JDeveloper".

Configuring the toplink-ejb-jar.xml File

This section describes:

For more information, see:

Creating toplink-ejb-jar.xml During Migration

EJB 2.1 only; When you migrate an Orion CMP application to TopLink persistence (see "Migrating to the TopLink Persistence Manager"), the TopLink migration tool automatically creates a toplink-ejb-jar.xml file for you.After generation, you can use the TopLink Mapping Workbench to customize and re-export (see "Understanding the TopLink Workbench" in the Oracle TopLink Developer's Guide).

Creating toplink-ejb-jar.xml with TopLink Workbench

For EJB 3.0 projects, if the only JDK 1.5 language extension that your entity classes use are annotations, you can use the TopLink Workbench to create and configure a toplink-ejb-jar.xml file. Oracle recommends using the TopLink Workbench to create and configure this file.

For EJB 2.1 projects, you use the TopLink Workbench to configure persistence properties in the toplink-ejb-jar.xml file. When you migrate an Orion CMP application to TopLink persistence (see "Migrating to the TopLink Persistence Manager"), the TopLink migration tool automatically creates a TopLink Workbench project for you. You can use the TopLink Workbench project to create a toplink-ejb-jar.xml file.

For more information, see:

Configuring the orion-ejb-jar.xml File

When you deploy an EJB application to sOC4J, you must specify any vendor-specific configuration in one of the following ways:

For more information, see "What is the orion-ejb-jar.xml File?".

Configuring the ejb3-toplink-sessions.xml File

This section describes:

For more information, see "What is the ejb3-toplink-sessions.xml File?".

Creating ejb3-toplink-sessions.xml with TopLink Workbench

For EJB 3.0 applications, if the only JDK 1.5 language extension that your entity classes use are annotations, you can use the TopLink Workbench to create and configure a ejb3-toplink-sessions.xml file. Oracle recommends using the TopLink Workbench to create and configure this file.

For more information, see:

Configuring the persistence.xml File

This section describes:

For more information, see "What is the persistence.xml File?".

Configuring a Named Persistence Unit in the persistence.xml File

Example 26-1 shows an example persistence.xml file that contains one persistence unit.

Example 26-1 Named Persistence Unit

<persistence-unit name="OrderManagement5">
    <provider>com.acme.persistence</provider>
    <transaction-type>RESOURCE_LOCAL</transaction-type>
    <mapping-file>order1.xml</mapping-file>
    <jar-file>order.jar</jar-file>
    <class>com.acme.Order</class>
    <properties>
        <property name="com.acme.persistence.sql-logging" value="on"/>
    </properties>
</persistence-unit>

This persistence unit is named OrderManagement5 and uses EntityManager provider com.acme.persistence. Its <transaction-type> specifies that this persistence unit requires only a non-JTA data source. It defines its set of persistent managed classes using all of <mapping-file>, <jar-file>, and <class> elements (see "What Persistent Managed Classes Does this Persistence Unit Include?"). It sets property com.acem.persistence.sql.logging to a value of on using a <property> element.

For detailed descriptions of <persistence-unit> element attributes and sub-elements, see the EJB 3.0 specification.

What Persistent Managed Classes Does this Persistence Unit Include?

You can specify the persistent managed classes associated with a persistence unit by using one or more of the following:

  • <mapping-file> element: specifies one or more object/relational mapping XML files (orm.xml files).

  • <jar-file> element: specifies one or more JAR files that will be searched for classes.

  • <class> element: specifies an explicit list of classes

  • The annotated managed persistence classes contained in the root of the persistence unit

    The root of the persistence unit is the JAR file or directory whose META-INF directory contains the persistence.xml file. To exclude managed persistence classes, add an <exclude-unlisted-classes> element to the persistence unit.

Configuring the persistence.xml File for the OC4J Default Persistence Unit

Using the OC4J default persistence unit, you can acquire an entity manager without having to specify a persistence unit by name (see "Understanding the OC4J Default Persistence Unit").

By default, to use the OC4J default persistence unit, you do not need to deploy a persistence.xml file at all.

If you set orion-ejb-jar.xml file attribute disable-default-persistent-unit to true, OC4J will expect a persistence.xml file. In this case, you can still use the OC4J default persistence unit if you specify an empty persistence unit: configure your persistence.xml file with an empty persistence unit using any of the following:

  • Empty <persistence> element:

    <persistence>
    </persistence>
    
    
  • Self-closing <persistence/> element

  • Completely empty (zero length) persistence.xml file

You may specify one and only one such empty persistence unit in your application.