Configuring J2EE Application XML Files

In this fourth part of a series covering the management of OC4J and configuring J2EE applications with Oracle 10g Application Server, we take a closer look at at J2EE application deployment files and more. This article is excerpted from chapter eight of the Oracle 10g Application Server Exam Guide, written by Sam Alapati (McGraw-Hill; ISBN: 0072262710).

J2EE Application Deployment Files

Now that you have reviewed the OC4J server XML files (which include the server configuration files and the Web site configuration file), let’s turn our attention to J2EE application XML files. There are two basic types of application configuration XML files: J2EE deployment (configuration) files and an OC4J-specific configuration file.

The application configuration XML files are meant for deployment of J2EE applications defined in an Enterprise Application Archive (EAR) file. The applications can include Web application components such as servlets and JSP pages, as well as EJB applications. A J2EE application can contain various types of modules, listed as follows:

  1. Web applications modules (WAR files), which include servlets and JSP pages
  2. EJB applications modules (EJB JAR files), which include Enterprise JavaBeans (EJBs)
  3. Client applications contained in JAR files (JSPs)
  4. Connectors

In order to deploy an application to OC4J, you archive the JAR and WAR files that belong to the enterprise Java application into an EAR file, whose layout follows J2EE specifications.

Applications that include only a Web application are bound to a UR, to make the application accessible to the Web clients. Applications with the EJB application component, however, aren’t bound to a URL. These can be accessed either through Remote Method Invocation (RMI) or locally, through the JVM running on a server.

OracleAS lets you create clusters of OC4J processes. The Oracle Enterprise Manager provides built-in support for managing such OC4J clusters across the enterprise. You must, therefore, rely on the Oracle Enterprise Manager 10g (Grid Control) and not use the admin.jar tool to manage the OC4 instance by itself. For the same reason, you are advised not to edit a single OC4J instance configuration file directly, but rather, use the Application Server Control. Although only the EJB modules and Web modules have been described thus far, there are actually four J2EE application types: EJB, Servlet (Web modules), JSP, and Client. You’ve already seen that J2EE applications have two types of deployment (or configuration) files, namely:

  • A J2EE deployment descriptor XML file (stored in the $ORACLE_HOME/applications/<app-name> directory)
  • An OC4J-specific deployment descriptor XML file (stored in the $ORACLE_HOME/application-deployments/<app-name> directory), denoted by the prefix of orion

You thus end up with a total of eight J2EE Deployment XML files for the four types of applications, four of which are the OC4J-specific Orion XML files and the other four, J2EE XML files.

In addition to the eight possible J2EE deployment XML files, you have a set of four common global configuration files for all types of applications. The four global application configuration files are as follows:

  • application.xml   This is the global application configuration file, which contains the common settings for all applications in an OC4J instance. 

  •  orion-application.xml   This contains OC4J-specific global application information for all applications.

  • web-application.xml   This contains OC4J-specific global Web application configuration information that specifies common settings for all Web modules. 
  • oc4j-connectors.xml   This contains information about global connector configuration.

on the job:  The J2EE deployment descriptors are a Java standard, and the application developers provide these (probably as generated by their IDE) to the administrator; subsequently, the OC4J Orion files are generated from these by OracleAS when you deploy the application.

To summarize our discussion, you can have the following J2EE application deployment files in an OC4J environment:

  1. Four common Global Configuration Files: application.xml, orion-application.xml, global-web-application.xml, and oc4j-connectors.xml
  2. Two configuration files for each of the four J2EE application types, one a J2EE deployment descriptor and the other an OC4J-specific deployment descriptor. The resulting files are the following:
    • For EJBs: ejb-jar.xml and orion-ejb-jar.xml
    • For Web modules: web.xml and orion-web.xml
  • For client modules: application-client.xml and orion-application-client.xml
  • For connectors: ra.xml and oc4j-ra.xml

In the following subsections, the main application XML configuration files are discussed briefly.

exam watch:   If you don’t create the OC4J-specfic deployment XML files, they will be automatically created when you deploy J2EE applications.

{mospagebreak title=Description of the Application (J2EE Deployment) XML Files}

In this section, each of the eight types of application XML files, also known as the J2EE Deployment XML Files, are discussed. First, let’s review the four common global application configuration files.

Following are the four common global configuration files for all J2EE application components.

on the job:  All the configuration XML files starting with Orion are also referred to as OC4J-Specific Orion files. The other set of configuration files consist of J2EE-related XML files.

The J2EE application.xml File

The J2EE application.xml file is stored in the j2ee/home/config directory and is

exam watch:  The application.xml file is the main J2EE application deployment descriptor file.

the global application configuration file for all J2EE applications in an OC4J instance. The application.xml file identifies all the Web and EJB applications that are part of a J2EE application. This file points to the location of the jazn-data.xml and the data-sources.xml file. Note that the J2EE application.xml file isn’t the same as the local application.xml files. The latter describe the J2EE EAR files.

The following subsections state the important elements in the application.xml file. The <application> element is the top element in the application.xml file. Within the <application> element, you can use the following elements.

<ejb>pathToEJB.jar</ejb>   The ejb element refers to an EJB JAR.

<alt-dd>path/to/dd</alt-dd>   The alt-dd element represents an optional Uniform Resource Indicator (URI) to the deployment descriptor file for a J2EE module. The deployer will read the deployment descriptor from the default location if you don’t specify the alt-dd element.

<connector>context</connector>   The connector element refers to the URI of a resource adapter archive file.

<context-root>thedir/</context-root>   The context-root descriptor shows the URI of a Web application.

<description>A description.</description>   The description element is a simple description of the application being deployed.

<icon>   The icon element is used to specify the location of application images used in GUI tools.

<java>pathToClient.jar</java>   The java element refers to a Java application client module.

<module>   There are as many module elements as there are separate J2EE modules, and each of them contains EJB, Java, and Web elements.

<web>   The Web element shows the web-uri and the context-root of a Web application module. The <web-uri> element indicates the URI of a Web application file. (A URI is an Internet protocol element consisting of a name or address you can use to refer to a resource. A URL is just an URI that additionally provides a way of accessing and obtaining a representation of the resource.) The URI is relative to the top level of the application package. Here’s the syntax for the <web> element: 

  <web-uri>thePathToThe.war</web-uri>

Here’s a simple application.xml file:

  <application>
    <display-namemyapp j2ee application</display-name>
    <description>
       A sample J2EE application that uses a Container Managed
      
Entity Bean and JSPs for a client. 
    </description>
    <module>
      <ejb>myapp-ejb.jar</ejb>
    </module>
    <module>
      <web>
        <web-uri>myapp-web.war</web-uri>
        <context-root>/myapp</context-root>
     
</web>
    </module>
  </application>

{mospagebreak title=The orion-application.xml File}

The orion-application.xml file is the OC4J-specific global configuration file for all applications in an OC4J instance. You specify the following types of configuration information in the orion-application.xml file:

  1. autocreate-tables and autodelete-tables: You must define a data source for all container-managed persistence (CMP) beans. The autocreate-tables attributes determine whether to automatically create tables for CMP beans for entity bean persistence, thus ensuring that fields and database types are mapped correctly. The autodelete-tables attribute determines whether to automatically delete the tables. By default, autocreate-tables is set to true and autodelete-tables is set to false.
  2. Default data sources for CMP beans
  3. Default security user manager
  4. JNDI authorization

If you want to bind EJBs to existing database tables, set the autocreate-tables attribute to false. You then deploy the EJB in a .ear file. Finally, you reconfigure the newly generated orion-ejb-jar.xml file so it uses the existing database tables.

global-web-application.xml   The global-web-application.xml file contains common settings for all the Web modules in an OC4J instance. The file contains OC4J-specific global Web application configuration details.

oc4j-connectors.xml   The oc4j-connectors.xml file is a connector configuration file that contains the global OC4J-specific connector configuration information.

Now that you’ve reviewed the four global J2EE configuration files, let’s turn our attention to the two types of configuration files (J2EE-specific files and OC4J-specific files) that each of the four application types (EJB, Web module, client, and connector) can have.

EJB

The EJB-related XML files are J2EE EJB application configuration files, used to define EJB deployment descriptors; they are part of the EJB JAR file. There are two EJB XML files: the J2EE ejb-jar.xml file and the OC4J-specific orion-ejb-jar.xml file.

J2EE ejb-jar.xml   The ejb-jar.xml file defines EJB deployment parameters in a JAR file. If you’re using CMP, the file contains definitions for the container-managed EJBs.

OC4J-Specific orion-ejb-jar.   The orion-ejb-jar.xml file defines OC4J-specific deployment descriptors for EJBs and thus contains the deployment time information for EJBs. The file provides the mapping for EJBs to the OC4J server environment. You can specify the following attributes in the orion-ejb-jar.xml file:

  1. Session persistence settings
  2. Time-out settings
  3. Transaction retry settings
  4. CMP, ORMI, and JNDI mappings

The orion-ejb-jar.xml file is located in the $ORACLE_HOME/j2ee/home/ application-deployments directory. After you deploy an application, you’ll find the orion-ejb-jar.xml file in the /deploymentName/jarname(.jar)/orion-ejb-jar.xml directory. If you bundle the EJB with the application or if you don’t specify a deployment directory in the OC4J main configuration file (server.xml), the orion-ejb-jar.xml file will be stored under the META-INF/orion-ejb-jar.xml directory.

The orion-ejb-jar.xml file will be copied to the directory specified for the deployment-directory attribute, but only if there are no prior files in that directory. Note that that you use the orion-ejb-jar.xml file only for the initial configuring of an application deployment. After this, the OC4J instance will modify the files to add pertinent information to it.

{mospagebreak title=Web Module}

There are two Web-related XML files, one of which is the J2EE-specific XML file and the other, the OC4J-specific XML file.

J2EE web.xml   All servlets, EJBs, and JSPs that are part of the J2EE application are described in the J2EE web.xml file. Here are the contents of a typical web.xml file:

  <web-app>
     <display-name>myapp web application</display-name>
     <description>
        Web module that contains an HTML welcome page, and 4
  JSP’s.
     </description>
     <welcome-file-list>
        <welcome-file>index.html</welcome-file>
     </welcome-file-list>
     <ejb-ref>
        <ejb-ref-name>TemplateBean</ejb-ref-name>
        <ejb-ref-type>Entity</ejb-ref-type>
        <home>TemplateHome</home>
        <remote>Template</remote>
    
</ejb-ref>
     <servlet>
        <servlet-name>template</servlet-name>
        <servlet-class>TemplateServlet</servlet-class>
        <init-param>
          
<param-name>length</param-name>
           <param-value>1</param-value>
        </init-param>
     </servlet>
  </web-app>

OC4J-Specific orion-web.xml   The orion-web.xml file contains the mappings for Web settings. Here are important items that are part of this file:

  1. Auto-reloading
  2. Buffering
  3. Directory browsing
  4. Document root
  5. Virtual directories
  6. Clustering
  7. Session tracking
  8. JNDI mappings

{mospagebreak title=Client} 

There are two XML files that contain client configuration information: application-client.xml and orion-application-client.xml.

J2EE application-client.xml   The application-client.xml file contains the JNDI information necessary for accessing the server application.

  <application-client>
        <display-name>TemplateBean</display-name>
        <ejb-ref> 
              <ejb-ref-name>TemplateBean</ejb-ref-name> 
             
<ejb-ref-type>Entity</ejb-ref-type>
             
<home>mTemplateHome</home>
              <remote>Template</remote>
        </ejb-ref>
  </application-client>

OC4J-Specific orion-application-client.xml   The orion-application-client.xml file contains JNDI mappings for the client. The JNDI mappings map the EJB reference logical name to the JNDI name for the EJB, as shown in this example:

  <orion-application-client>
    
<ejb-ref-mapping name="TemplateBean"
     location="myapp/myapp-ejb/TemplateBean" />
 
</orion-application-client>

Connector

There are two connector-related XML files: ra.xml and oc4j-ra.xml.

ra.xml   The ra.xml file contains J2EE-related configuration information.

oc4j-ra.xml   The oc4j-ra.xml file contains OC4J-specific configuration information.

Using the Application Server Control to Configure OC4J

In the previous subsections, you learned how to manually edit the various OC4J configuration files. However, you can change OC4J configuration easily through the Application Server Control. To edit OC4J server configuration files using the Application Server Control, follow these steps:

  1. On the OC4J home page, click the Administration tab to display the Administration page.
  2. On the Administration page, click the Advanced Properties button.
  3. The OC4J Advanced Properties page appears listing all configuration files available for editing for the current OC4J server.
  4. The OC4J Advanced Properties Page appears, listing all the OC4J configuration files you can edit. Click the configuration file you want to edit. You can then make your configuration changes in the editable text box that appears.
  5. Click the Apply button to save your configuration changes.

Please check back next week for the continuation of this article.

[gp-comments width="770" linklove="off" ]
antalya escort bayan antalya escort bayan