Skip Headers

Oracle Application Server Containers for J2EE Stand Alone User's Guide
10g (9.0.4)

Part Number B10323-01
Go To Documentation Library
Home
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

2
Advanced Configuration,
Development, and Deployment

This chapter provides information for administering OC4J in standalone mode for development purposes. Chapter 1, "Configuration and Deployment", discusses the easiest method for configuring, developing, and deploying a J2EE application. However, if you want to use other services, such as JMS, you must know how to manipulate the XML configuration files.

This chapter discusses the following topics:

Overview of OC4J and J2EE XML Files

This section contains the following topics:

XML Configuration File Overview

Because OC4J is configured solely through XML files, you must understand the role and method for a set of XML files. Each XML file exists to satisfy a certain role; thus, if you have need of that role, you will understand which XML file to modify and maintain.

Figure 2-1 illustrates all the OC4J XML files and their respective roles.

Figure 2-1 OC4J and J2EE Application Files

Text description of o_1009.gif follows.

Text description of the illustration o_1009.gif


Note:

Each deployed application uses an application.xml as the standard J2EE application descriptor file. That XML file is local to the application and separate from the application.xml that exists in the j2ee/home/config directory. The j2ee/home/config/application.xml file configures options that are applied to all applications deployed in this OC4J server instance.


Table 2-1 describes the role and function for each XML file that was displayed in the preceding figure.

Table 2-1 OC4J Features and Components  
XML Configuration File Features/Components

server.xml

OC4J overall server configuration. Configures the server and points to the XML files that add to this file, such as jms.xml for JMS support. The listing of other XML files enables the services to be configured in separate files, but the server.xml file denotes that they be used for the OC4J configuration.

principals.xml

OC4J security configuration for the type of security required for accessing the server.

data-sources.xml

OC4J data source configuration for all databases used by applications within OC4J.

rmi.xml

OC4J RMI port configuration and RMI tunneling over HTTP.

jms.xml

OC4J JMS configuration for Destination topics and queues that are used by JMS and MDBs in OC4J.

*-web-site.xml

OC4J Web site definition. Each Web site is defined within its own XML file. It is a good practice to name each XML file based on the root element name, <web-site>. For example, *-web-site.xml could be my-web-site.xml. Normally, the global Web site definition is in http-web-site.xml. You must specify each Web site XML file in its own web-site path statement contained within the server.xml file.

application.xml
orion-application.xml

J2EE application standard J2EE application descriptor file and configuration files.

  • The global application.xml file exists in the j2ee/home/config directory and contains common settings for all applications in this OC4J instance. This file defines the location of the security XML definition file--principals.xml. This is a different XML file than the local application.xml files.

  • The local application.xml file defines the J2EE EAR file, which contains the J2EE application modules. This file exists within the J2EE application EAR file.

  • The orion-application.xml file is the OC4J-specific definitions for all applications.

global-web-application.xml
web.xml
orion-web.xml

J2EE Web application configuration files.

  • global-web-application.xml is an OC4J-specific file for configuring servlets that are bound to all Web sites.

  • web.xml and orion-web.xml for each Web application.

The web.xml files are used to define the Web application deployment parameters and are included in the WAR file. In addition, you can specify the URL pattern for servlets and JSPs in this file. For example, servlet is defined in the <servlet> element, and its URL pattern is defined in the <servlet-mapping> element.

ejb-jar.xml
orion-ejb-jar.xml

J2EE EJB application configuration files. The ejb-jar.xml files are used to define the EJB deployment descriptors and are included in the EJB JAR file.

application-client.xml
orion-application-client.xml

J2EE client application configuration files.

oc4j-connectors.xml
ra.xml
oc4j-ra.xml

Connector configuration files.

  • The oc4j-connectors.xml file contains global OC4J-specific configuration for connectors.

  • The ra.xml file contains J2EE configuration.

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

XML File Interrelationships

Some of these XML files are interrelated. That is, some of these XML files reference other XML files--both OC4J configuration and J2EE application (see Figure 2-3).

Here are the interrelated files:

The server.xml file is the keystone that contains references to most of the files used within the OC4J server. Figure 2-2 shows the XML files that can be referenced in the server.xml file:

Figure 2-2 XML Files Referenced Within server.xml

Text description of o_1060.gif follows.

Text description of the illustration o_1060.gif

Figure 2-3 demonstrates how the server.xml points to other XML configuration files. For each XML file, the location can be the full path or a path relative to the location of where the server.xml file exists. In addition, the name of the XML file can be any name, as long as the contents of the file conform to the appropriate DTD.

In addition to pointing to the OC4J server configuration files, the server.xml file describes the applications that have been deployed to this OC4J server. You can deploy applications through the admin.jar command using the -deploy option or by modifying the server.xml file directly. Each deployed application is denoted by the <application> element. See "Manually Adding Applications in a Development Environment" for more information on directly editing the server.xml file.

Figure 2-3 Server.xml File and Related XML Files

Text description of o_1010.gif follows.

Text description of the illustration o_1010.gif

Other elements for server.xml are described in "Elements in the server.xml File".

What Happens When You Deploy?

Whether you deploy the application through the admin.jar command or by editing XML files, the following occurs:

OC4J opens the EAR file and reads the descriptors.

  1. OC4J opens, parses the application.xml that exists in the EAR file. The application.xml file lists all of the modules contained within the EAR file. OC4J notes these modules and initializes the EAR environment.

  2. OC4J reads the module deployment descriptors for each module type: Web module, EJB module, connector module, or client module. The J2EE descriptors are read into memory. If OC4J-specific descriptors are included, these are also read into memory. The JAR and WAR file environments are initialized.

  3. OC4J notes any unconfigured items that have defaults and writes these defaults in the appropriate OC4J-specific deployment descriptor. Thus, if you did not provide an OC4J-specific deployment descriptor, you will notice that OC4J provides one written with certain defaults. If you did provide an OC4J-specific deployment descriptor, you may notice that OC4J added elements.

  4. OC4J reacts to the configuration details contained in both the J2EE deployment descriptors and any OC4J-specific deployment descriptors. OC4J notes any J2EE component configurations that require action on OC4J's part, such as wrapping beans with their interfaces.

  5. After defaults have been added and necessary actions have been taken, OC4J writes out the new module deployment descriptors to the application-deployments/ directory. These are the descriptors that OC4J uses when starting and restarting your application. But do not modify these descriptors. Always change your deployment descriptors in the "master" location.

  6. OC4J copies the EAR file to the "master" directory. This defaults to the applications/ directory. However, you can designate where the "master" directory is by the admin.jar -targetPath option.


    Note:

    If you deploy this EAR file using admin.jar without removing the EAR file from the applications/ directory, the new deployment renames the EAR file prepended with an underscore. It does not copy over the EAR file. Instead, you can copy over the EAR file. OC4J notices the change in the timestamp and redeploys.


  7. Finally, OC4J updates the server.xml file with the notation that this application has been deployed.

Sharing Libraries

If you have libraries that you want to share among applications, add a <library> element in the global application.xml file, indicating the directory where you are placing the libraries, as follows:

Windows:

<library path="d:\oc4j\j2ee\home\applib\"/>

UNIX:

<library path="/private/oc4j/j2ee/home/applib/"/>

For each directory to be included, use a separate <library> element on a separate line, as follows:

<library path="/private/oc4j/j2ee/home/applib/"/>
<library path="/private/oc4j/j2ee/home/mylibrary/"/>

As a default, a <library> element exists in the global application.xml file with the j2ee/home/applib directory. Instead of modifying the <library> element to contain other directories, you could move your libraries into the applib directory. However, note that adding libraries to this directory increases the size of OC4J and effects the performance as all libraries are searched for unknown classes. Use this with discretion.


Note:

The default j2ee/home/applib directory is not created when OC4J is installed. If you want to add shared libraries to this directory, you must first create it before adding your libraries.


If you can, you should keep your shared libraries local to the application through the orion-application.xml file deployed with the application. You can add <library> elements in the orion-application.xml file for the application to indicate where the libraries are located, which are used only within the application.

Manually Adding Applications in a Development Environment

When you are in a development environment, it is sometimes easier to modify XML files than to use the admin.jar command for each iteration of development. The following sections help you understand how to modify your XML configuration files:

Configuring a Listener

Each OC4J server is configured to listen on HTTP or RMI protocols for incoming requests. Each OC4J Web server is configured within its own *-web-site.xml file.

Configuring J2EE Applications

To configure and deploy your J2EE applications, modify the server.xml and http-web-site.xml files with your application information.

Building and Deploying Within a Directory

When developing applications, you want to quickly modify, compile, and execute your classes. OC4J can automatically deploy your applications as you are developing them within an expanded directory format. OC4J automatically deploys applications if the timestamp of the top directory, noted by appname in Figure 2-4, changes. This is the directory that server.xml knows as the "master" location.

The application must be placed in the "master" directory in the same hierarchical format as necessary for JAR, WAR, and EAR files. For example, if appname is the directory where your J2EE application resides, Figure 2-4 displays the necessary directory structure.

Figure 2-4 Development Application Directory Structure

Text description of advance5.gif follows

Text description of the illustration advance5.gif

To deploy EJB or complex J2EE applications in an expanded directory format, complete the following steps:

  1. Place the files in any directory. Figure 2-4 demonstrates an application placed into j2ee/home/applications/appname/. The directory structure below appname is similar to that used within an EAR file, as follows:

    1. Replace the EJB JAR file name, Web application WAR file name, client JAR file name, and Resource Adapter Archive (RAR) file name with a directory name of your choosing to represent the separate modules. Figure 2-4 demonstrates these directory names by ejb_module/, web_module/, client_module/, and connector_module/.

    2. Place the classes for each module within the appropriate directory structure that maps to their package structure.

  2. Modify the server.xml, application.xml, and *-web-site.xml files. The server.xml and *-web-site.xml files are located in j2ee/home/config directory, while the application.xml is under j2ee/home/applications/<appname>/META-INF directory. Modify these files as follows:

    • In server.xml, add a new or modify the existing <application name=... path=... auto-start="true" /> element for each J2EE application. The path points to the "master" application directory. In Figure 2-4, this is j2ee/home/applications/appname/.

      You can specify the path in one of two manners:

      • Specifying the full path from root to the parent directory.

        In the example in Figure 2-4, if appname is "myapp", then the fully-qualified path is as follows:

        <application_name="myapp"
            path="/private/j2ee/home/applications/myapp"  
            auto-start="true" />
        
        
      • Specifying the relative path. The path is relative to where the server.xml file exists to where the parent directory lives.

        In the example in Figure 2-4, if appname is "myapp", then the relative path is as follows:

        <application_name="myapp" path="../applications/myapp" 
        auto-start="true" />
        
        
    • In application.xml, modify the <module> elements to contain the directory names for each module--not JAR or WAR files. You must modify the <web-uri>, the <ejb>, and the <client> elements in the application.xml file to designate the directories where these modules exist. The path included in these elements should be relative to the "master" directory and the parent of the WEB-INF or META-INF directories in each of these application types.

      For example, if the web_module/ directory in Figure 2-4 was "myapp-web/", then the following example designates this as the Web module directory within the <web-uri> element as follows:

      <module>
        <web>
          <web-uri>myapp-web</web-uri>
        </web>
      </module>
      
      
    • In the *-web-site.xml file, add a <web-app...> element for each Web application. This is important, because it binds the Web application within the Web site. The application attribute value should be the same value as that provided in the server.xml file. The name attribute should be the directory for the Web application. Note that the directory path given in the name element follows the same rules as for the path in the <web-uri> element in the application.xml file.

      To bind the"myapp" Web application, add the following:

      <web-app application="myapp" name="myapp-web" root="/myapp" /> 
      


      Note:

      You achieve better performance if you are deploying with an EAR file. During execution, the entire EAR file is loaded into memory and indexed. This is faster than reading in each class from the development directory when necessary.


OC4J Automatic Deployment for Applications

OC4J automatically deploys an application if the timestamp on an EAR file has changed. Restarting OC4J to deploy or redeploy applications is not necessary. Automatic deployment is not enabled in all cases, but deployment occurs in the following cases:

When OC4J does not check for updates, redeploy by either using the admin.jar command-line tool or restarting the OC4J server manually. See "Options for the OC4J Administration Management JAR" for a description of the -deploy option.

Changing XML Files After Deployment

Whenever you deploy an application, OC4J automatically generates the OC4J-specific XML files with the default elements. If you want to change these files or add to the existing XML files, you must copy the XML files to where your original development directory for the application and change it in this location. If you change the XML file within the deployed location, OC4J simply overwrites these changes when the application is deployed again. The changes only stay constant when changed in the development directories.

For all OC4J-specific XML files, you can add these files within the recommended development structure as shown in Figure 2-5.

Figure 2-5 Development Application Directory Structure

Text description of advance2.gif follows

Text description of the illustration advance2.gif

Designating a Parent of Your Application

A child application can see the namespace of its parent application. Thus, setting up an application as a parent is used to share services among children. The default parent is the global application.

To set up an application as a parent of another, you can do one of the following:

Developing Startup and Shutdown Classes

You can develop classes that are called after OC4J initializes or before OC4J terminates. Startup classes can start services and perform functions after OC4J initiates; shutdown classes can terminate these services and perform functions before OC4J terminates. The oc4j.jar must be in the Java CLASSPATH when you compile these classes.

OC4J deploys and executes the OC4J startup and shutdown classes based on configuration of these classes in the server.xml file.

OC4J Startup Classes

Startup classes are executed only once after OC4J initializes. They are not re-executed everytime the server.xml file is touched. Your startup class implements the com.evermind.server.OC4JStartup interface that contains two methods--preDeploy and postDeploy--in which you can implement code for starting services or performing other initialization routines.

Each method requires two arguments--a Hashtable that is populated from the configuration and a JNDI Context to which you can bind to process values contained within the Context. Both methods return a String, which is currently ignored.

Once created, you must configure the startup class within the <startup-classes> element in the server.xml file. Each OC4JStartup class is defined in a single <startup-class> element within the <startup-classes> element. Each <startup-class> defines the following:

In the <init-library path="../[xxx]" /> element in the server.xml file, configure the directory where the startup class resides, or the directory and JAR filename where the class is archived. The path attribute can be fully-qualified or relative to j2ee/home/config.

Example 2-1 Startup Class Example

The configuration for the TestStartup class is contained within a <startup-class> element in the server.xml file. The configuration defines the following:

Thus, configure the following in the server.xml file to define the TestStartup class:

<startup-classes>
        <startup-class classname="TestStartup" failure-is-fatal="true">
            <execution-order>0</execution-order>
                <init-param>
                    <param-name>oracle.test.startup</param-name>
                    <param-value>true</param-value>
                </init-param>
                <init-param>
                    <param-name>startup.oracle.year</param-name>
                    <param-value>2002</param-value>
                </init-param>
        </startup-class>
 </startup-classes>

The container provides the two initialization kay-value pairs within the input Hashtable parameter to the startup class.

The following example shows TestStartup, which implements the com.evermind.server.OC4JStartup interface. The preDeploy method retrieves the key-value pairs from the Hashtable and prints them out. The postDeploy method is a null method. The oc4j.jar must be in the Java CLASSPATH when you compile TestStartup.

import com.evermind.server.OC4JStartup;

import javax.naming.*;
import java.util.*;

public class TestStartup implements OC4JStartup {
    public String preDeploy(Hashtable args, Context context) throws Exception {
        // bind each argument using its name
        Enumeration keys = args.keys();
        while(keys.hasMoreElements()) {
            String key = (String)keys.nextElement();
            String value = (String)args.get(key);
            System.out.println("prop: " + key + " value: " + args.get(key));
            context.bind(key, value);
        }

        return "ok";
    }

    public String postDeploy(Hashtable args, Context context) throws Exception {
        return null;
    }
}

Assuming that the TestStartup class is archived in "../app1/startup.jar", modify the <init-library> element in the server.xml file as follows:

<init-library path="../app1/startup.jar" />

When you start OC4J, the preDeploy method is executed before any application is initialized. OC4J populates the JNDI context with the values from the Hashtable. If TestStartup throws an exception, then OC4J exits since the failure-is-fatal attribute was set to TRUE.

OC4J Shutdown Classes

Shutdown classes are executed before OC4J terminates. Your shutdown class implements the com.evermind.server.OC4JShutdown interface that contains two methods--preUndeploy and postUndeploy--in which you can implement code for shutting down services or perform other termination routines.

Each method requires two arguments--a Hashtable that is populated from the configuration and a JNDI Context to which you can bind to process values contained within the Context.

The implementation and configuration is identical to the shutdown classes as described in "OC4J Startup Classes" with the exception that the configuration is defined within the <shutdown-classes> and <shutdown-class> elements and there is no failure-is-fatal attribute. Thus, the configuration for a TestShutdown class would be as follows:

<shutdown-classes>
        <shutdown-class classname="TestShutdown">
            <execution-order>0</execution-order>
                <init-param>
                    <param-name>oracle.test.shutdown</param-name>
                    <param-value>true</param-value>
                </init-param>
                <init-param>
                    <param-name>shutdown.oracle.year</param-name>
                    <param-value>2002</param-value>
                </init-param>
        </shutdown-class>
 </shutdown-classes>

Assuming that the TestShutdown class is archived in "../app1/shutdown.jar", add another <init-library> element in the server.xml file as follows:

<init-library path="../app1/shutdown.jar" />

Setting Performance Options

Most performance settings are discussed in the Oracle Application Server 10g Performance Guide.

You can manage these performance settings yourself from either the OC4J command-line option or by editing the appropriate XML file element.

Performance Command-Line Options

Each -D command-line option, except for the dedicated.rmicontext option, defaults to the recommended setting. However, you can modify these options by providing each -D command-line option as an OC4J option. See the "Standalone OC4J Command-Line Options and Properties" for an example.

Thread Pool Settings

You can specify an unbounded, one, or two thread pools for an OC4J process through the <global-thread-pool> element in the server.xml file. If you do not specify this element, then an infinite number of threads can be created, which is the unbounded option.

There are two types of threads in OC4J:

OC4J always maintains a certain amount of worker threads, so that any client connection traffic bursts can be handled.

If you specify a single thread pool, then both short and long lived threads exist in this pool. The risk is that all the available threads in the pool are one type of thread. Then, performance can be poor because of a lack of resources for the other type of thread. However, OC4J always guarantees a certain amount of worker threads, which are normally mapped to short lived threads. If a need for a worker thread arises and no short lived thread is available, the work is handled by a long lived thread.

If you specify two thread pools, then each pool contains one type of thread.

To create a single pool, configure the min, max, queue, and keepAlive attributes. To create two pools, configure the min, max, queue, and keepAlive attributes for the first pool and the cx-min, cx-max, cx-queue, and cx-keepAlive attributes for the second pool. In order to activate two thread pools, you must configure all the attributes for the first thread pool, which includes min, max, queue, and keepAlive. If any of these attributes is not configured, you cannot configure the second pool. Instead, you will receive the following error message:

Error initializing server: Invalid Thread Pool parameter: null 

The global-thread-pool element provides the following attributes:

Table 2-2 The Thread Pool Attributes  
Thread Pool Attributes Description

min

The minimum number of threads that OC4J can simultaneously execute. By default, a minimum number of threads are preallocated and placed in the thread pool when the container starts. Value is an integer. The default is 20. The minimum value you can set this to is 10.

max

The maximum number of threads that OC4J can simultaneously execute. New threads are spawned if the maximum size is not reached and if there are no idle threads. Idle threads are used first before a new thread is spawned. Value is an integer. The default is 40.

queue

The maximum number of requests that can be kept in the queue. Value is an integer. The default is 80.

keepAlive

The number of milliseconds to keep a thread alive (idle) while waiting for a new request. This timeout designates how long an idle thread remains alive. If the timeout is reached, the thread is destroyed. The minimum time is a minute. Time is set in milliseconds. To never destroy threads, set this timeout to a negative one.

Value is a long. The default is 600000 milliseconds.

cx-min

The minimum number of connection threads that OC4J can simultaneously execute. Value is an integer. The default is 20. The minimum value you can set this to is 10.

cx-max

The maximum number of connection threads that OC4J can simultaneously execute. Value is an integer. The default is 40.

cx-queue

The maximum number of connection requests that can be kept in the queue. Value is an integer. The default is 80.

cx-keepAlive

The number of milliseconds to keep a connection thread alive (idle) while waiting for a new request. This timeout designates how long an idle thread remains alive. If the timeout is reached, the thread is destroyed. The minimum time is a minute. Time is set in milliseconds. To never destroy threads, set this timeout to a negative one.

Value is a long. The default is 600000 milliseconds.

debug

If true, print the application server thread pool information at startup. The default is false.

Recommendations:

Example 2-2 Setting Thread Pool

The following example initializes two thread pools for the OC4J process. Each contains at minimum 10 threads and maximum of 100 threads. The number of requests outstanding in each queue can be 200 requests. Also, idle threads are kept alive for 700 seconds. The thread pool information is printed at startup.

<application-server ...>
...
	<global-thread-pool min="10" max="100" queue="200" 
	keepAlive="700000" cx-min="10" cx-max="100" cx-queue="200" 
	cx-keepAlive="700000" debug="true"/>
...
</application-server>

Statement Caching

You can cache database statements, which prevents the overhead of repeated cursor creation and repeated statement parsing and creation. In the DataSource configuration, you enable JDBC statement caching, which caches executable statements that are used repeatedly. A JDBC statement cache is associated with a particular physical connection. See Oracle9i JDBC Developer's Guide and Reference for more information on statement caching.

You can dynamically enable and disable statement caching programmatically through the setStmtCacheSize() method of your connection object or through the stmt-cache-size XML attribute in the DataSource configuration. An integer value is expected with the size of the cache. The cache size you specify is the maximum number of statements in the cache. The user determines how many distinct statements the application issues to the database. Then, the user sets the size of the cache to this number.

If you do not specify this attribute or set it to zero, this cache is disabled.

Example 2-3 Statement Caching

The following XML sets the statement cache size to 200 statements.

<data-source>
 ...
 stmt-cache-size="200"
</data-source> 

Task Manager Granularity

The task manager is a background process that performs cleanup. However, the task manager can be expensive. You can manage when the task manager performs its duties through the taskmanager-granularity attribute in server.xml. This element sets how often the task manager is kicked off for cleanup. Value is in milliseconds. Default is 1000 milliseconds.

<application-server ...  taskmanager-granularity="60000" ...>

Enabling OC4J Logging

OC4J logs messages both to standard error, standard out, and several log files for OC4J services and deployed applications.

Viewing OC4J System and Application Log Messages

Each OC4J process included in the Oracle Application Server environment has a set of log files, as shown in Table 2-3. If there are multiple processes running for an OC4J instance, there is a multiple set of log files.

Table 2-3 List of Log Files Generated for OC4J
Default Log File Name Description Scope Configuration File

application.log

All events, errors, and exceptions for a deployed application.

One log file for each application deployed.

orion-application.
xml

global-application.log

All common events, errors, and exceptions related to applications.

All applications, including the default application.

application.xml

jms.log

All JMS events and errors.

JMS sub-system

jms.xml

rmi.log

All RMI events and errors.

RMI sub-system

rmi.xml

server.log

All events not associated with a particular sub-system or an application. This logs history of server startup, shutdown internal server errors.

server-wide

server.xml

web-access.log

Logs all accesses to the Web site.

Each Web site

http-web-site.xml

There are two types of log files:

Text Log Files

Full text logging is still available in OC4J. Primarily, you should use text logging within OC4J standalone. It is easier to read within any editor, as it is not in XML format.

The text logging facility separates messages out in alignment with the XML files. However, instead of writing to multiple log files of the same size, all messages for that component are written into a single file. The text logging does not have any imposed limits or log rollover. Instead, the log files will continue to grow, unless you stop OC4J, remove the file, and restart OC4J to start the log files over. You can overrun your disk space if you do not monitor your log files. This is only feasible in a standalone, development environment.

Text messaging is the default and is configured in the XML files in Table 2-3. Text messaging is enabled in the <file> subelement the <log> element of the XML files, except the http-web-site.xml file. For the http-web-site.xml file, the text messaging is enabled with the <access-log> element. To turn off text messaging, eliminate or comment out the <file> or <access-log> element. If you do not remove this line and enable ODL logging, you will have both logging facilities turned on. The location and filename for text messaging does have defaults, as shown in Table 2-4, but you can specify the location and filename within the path attribute of the <log> or <access-log> elements.

Table 2-4 shows the default location for the log files for a standalone OC4J. You can modify the location and names of these files by modifying the configuration files described in Table 2-3.

Table 2-4 OC4J Standalone Log File Locations  
Log File Default Location

application.log

install_dir/j2ee/home/application-deployments/<application-name>

global-application.log

install_dir/j2ee/home/log

jms.log

install_dir/j2ee/home/log

rmi.log

install_dir/j2ee/home/log

server.log

install_dir/j2ee/home/log

web-access.log

The location is configurable from *-web-site.xml with the <access-log> element, as follows: <access-log path="../log/http-web-access.log" />

The location of all of the above log files can be specified, except the web-access.log file, using the <log> element in the respective configuration files. You can specify either absolute paths or paths relative to the j2ee/home/config directory. For example, specify the server log file in the server.xml configuration file, as follows:

<log>
<file path="../log/my-server.log" />
</log>

You can also specify an absolute path for the location of the log file, as follows:

<log>
<file path="d:\log-files\my-server.log" />
</log>

Oracle Diagnostic Logging (ODL) Log Files

The ODL log entries are each written out in XML format in its respective log file. Each XML message can be read through your own XML reader. The advantages for ODL logging is that the log files and the directory have a maximum limit. When the limit is reached, the log files are overwritten.

When you enable ODL logging, each new message goes into the current log file, named log.xml. When the log file is full--that is, the log file size maximum is reached--then it is copied to an archival log file, named logN.xml, where N is a number starting at one. When the last log file is full, the following occurs:

  1. The least recent log file is erased to provide space in the directory.

  2. The log.xml file is written to the latest logN.xml file, where N increments by one over the most recent log file.

Thus, your log files are constantly rolling over and do not encroach on your disk space.

Within each XML file listed in Table 2-3, you enable ODL logging by uncommenting the ODL configuration line, as follows:

The attributes that you can configure are:

New files are created within the directory, until the maximum directory size is reached. Each log file is equal to or less than the maximum specified in the attributes.

Thus, to specify log files of 1000 KB and a maximum of 10,000 KB for the directory in the <install-dir>/j2ee/home/log/server directory in the server.xml file, configure the following:

<log>
<odl path="../log/server/" max-file-size="1000" max-directory-size="10000" />
</log>

When OC4J is executing, all log messages that are server oriented are logged in the <install-dir>/j2ee/home/log/server directory.

The XML message that is logged is of the following format:

<MESSAGE>
<HEADER>
<TSTZ_ORIGINATING>2002-11-12T15:02:07.051-08:00</TSTZ_ORIGINATING>
<COMPONENT_ID>oc4j</COMPONENT_ID>
<MSG_TYPE TYPE="ERROR"></MSG_TYPE>
<MSG_LEVEL>1</MSG_LEVEL>
<HOST_ID>myhost</HOST_ID>
<HOST_NWADDR>001.11.22.33</HOST_NWADDR>
<PROCESS_ID>null-Thread[Orion Launcher,5,main]</PROCESS_ID>
<USER_ID>dpda</USER_ID>
</HEADER>
<PAYLOAD>
<MSG_TEXT>java.lang.NullPointerException at 
com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:1070)
at com.evermind.server.ApplicationServerLauncher.run 
(ApplicationServerLauncher.java:93) at java.lang.Thread.run(Unknown Source)
</MSG_TEXT>
</PAYLOAD>
</MESSAGE/>

You can have both the ODL and text logging turned on. To save on disk space, you should turn off one of these options. If you decide to enable ODL logging, turn off the text logging functionality by commenting out the <file> subelement of the <log> element for all XML files except the http-web-site.xml file. For the http-web-site.xml file, turn off the text logging by commenting out the <access-log> element.

Redirecting Standard Out and Standard Error

Many developers use the System.out.println() and System.err.println() methods in their applications to generate debug information. Normally, the output from these method calls are printed to the console where the OC4J process is started. However, you can specify command-line options when starting OC4J to direct the STDOUT and STDERR output directly to files. The -out and -err parameters inform OC4J where to direct the error messages. The following startup command includes and example of the -out and -err parameters:

$ java -jar oc4j.jar -out d:\log-files\oc4j.out -err d:\log-files\oc4j.err 

In this case, all information written to STDOUT and STDERR is printed to the files d:\log-files\oc4j.out and d:\log-files\oc4j.err respectively.

OC4J Debugging

OC4J provides several debug properties for generating additional information on the operations performed by the various sub-systems of OC4J. These debug properties can be set for a particular sub-system while starting up OC4J.


Note:

Turning on excessive debug options can slow down the execution of your applications and use large amounts of disk space with the contents of the log files.


The following table provides useful debug options that available with OC4J. These debug options have two states either true or false. By default these are set to false. For a complete list of debug properties, see "OC4J System Properties".

Table 2-5 HTTP Debugging Options
HTTP Debugging Description of Option

http.session.debug

Provides information about HTTP session events

http.request.debug

Provides information about each HTTP request

http.error.debug

Prints all HTTP errors

http.method.trace.allow

Default: false. If true, turns on the trace HTTP method.

Table 2-6 JDBC Debugging Options
JDBC Debugging Description of Option

datasource.verbose

Provides verbose information on creation of data source and connections using Data Sources and connections released to the pool, and so on,

jdbc.debug

Provides very verbose information when JDBC calls are made

Table 2-7 RMI Debugging Options
RMI Debugging Description of Options

rmi.debug

Prints RMI debug information

rmi.verbose

Provides very verbose information on RMI calls

Table 2-8 OracleAS Web Services Debugging Options
OracleAS Web Services Debugging Description of Options

ws.debug

Turns on OracleAS Web Services debugging

For example, if you want to generate debug information on HTTP session events then you start OC4J, as follows:

java -Dhttp.session.debug=true -jar oc4j.jar

After OC4J is started with a specific debug option, debug information is generated and routed to standard output. In the above example, you would see HTTP session information on your OC4J console, as follows:

Oracle Application Server Containers for J2EE initialized 
Created session with id '36c04d8a1cd64ef2b6a9ba6e2ac6637e' at Mon Apr 15 
12:24:20 PDT 2002, secure-only: false
Created session with id '36c04d8a1cd64ef2b6a9ba6e2ac6637e' at Mon APR 15 
12:36:06 PDT 2002, secure-only: false 
Invalidating session with id '36c04d8a1cd64ef2b6a9ba6e2ac6637e' at Mon APR 15 
12:44:32 PDT 2002 (created at Mon APR 15 12:24:23 PDT 2002) due to timeout 

If you want to save this debug information, then you can redirect your standard output to a file using the -out or -err command-line options, as follows:

java -Dhttp.session.debug=true -jar oc4j.jar -out oc4j.out -err oc4j.err

In addition to the specific sub-system switches, you can also start OC4J with a supplied verbosity level. The verbosity level is an integer between 1 and 10. The higher the verbosity level, the more information that is printed in the console. You specify the verbosity level with the -verbosity OC4J option in the OC4J command-line options section. The following examples show the output with and without verbosity:

Example 2-4 Error Messages Displayed Without Veribosity

D:\oc4j903\j2ee\home>java -jar oc4j.jar 
Oracle Application Server Containers for J2EE initialized 

Example 2-5 Error Messages Displayed With Verbosity Level of 10

D:\oc4j903\j2ee\home>java -jar oc4j.jar -verbosity 10 
Application default (default) initialized... 
Binding EJB work.ejb.WorkHours to work.ejb.WorkHours... 
Application work (work) initialized... 
Application serv23 (Servlet 2.3 New Features Demo) initialized... 
Web-App default:defaultWebApp (0.0.0.0/0.0.0.0:8888) started... 
Oracle Application Server Containers for J2EE initialized 

Servlet Debugging Example

You deployed a Web application to OC4J that is having some problems with servlets. You are losing the client session when you use a pre-configured data source to make database connection. You want to know what OC4J is doing when the servlet is accessing the data source. In order to generate the debug information on HTTP Session and data source usage, you must set two debug options - http.session.debug and datasource.verbose to true.

java -Dhttp.session.debug=true -Ddatasource.verbose=true -jar oc4j.jar

Then, re-execute your servlet and see the following type of debug information in the standard output for the OC4J process:

DataSource logwriter activated... jdbc:oracle:thin:@localhost:1521:ORCL:
Started 
jdbc:oracle:thin:@localhost:1521:ORCL: Started 
Oracle Application Server Containers for J2EE initialized 
Created session with id '4fa5eb1b9a564869a426e8544963754f' at Tue APR 23
16:22:56 PDT 2002, secure-only: false 
Created new physical connection: XA XA OC4J Pooled
jdbc:oracle:thin:@localhost:1521:ORCL 
null: Connection XA XA OC4J Pooled jdbc:oracle:thin:@localhost:1521:ORCL
allocated (Pool size: 0) 
jdbc:oracle:thin:@localhost:1521:ORCL: Opened connection 
Created new physical connection: Pooled
oracle.jdbc.driver.OracleConnection@5f18 
Pooled jdbc:oracle:thin:@localhost:1521:ORCL: Connection Pooled
oracle.jdbc.driver.OracleConnection@5f1832 allocated (Pool size: 0) 
Pooled jdbc:oracle:thin:@localhost:1521:ORCL: Releasing connection Pooled 
oracle.jdbc.driver.OracleConnection@5f1832 to pool (Pool size: 1) 
null: Releasing connection XA XA OC4J Pooled
jdbc:oracle:thin:@localhost:1521:ORCL to pool (Pool size: 1) 
OC4J Pooled jdbc:oracle:thin:@localhost:1521:ORCL: Cache timeout, closing
connection (Pool size: 0) 
com.evermind.sql.OrionCMTDataSource/default/jdbc/OracleDS: Cache timeout,
closing connection (Pool size: 0) 


Go to previous page Go to next page
Oracle
Copyright © 2002, 2003 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Table Of Contents
Contents
Go To Index
Index