Oracle9i Servlet Engine Developer's Guide
Release 1 (9.0.1)

Part Number A90213-02
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

5
Configuring mod_ose

This chapter describes how to configure the Oracle HTTP Server (powered by Apache) and the Apache mod_ose module that is used to connect to the Oracle Servlet Engine (OSE/OJVM).

This chapter contains the following topics:

Steps to Take

To set up the Oracle HTTP Server and the mod_ose module that is used to connect Apache to the Oracle Servlet Engine (OSE/OJVM), you need to take the following steps:

  1. Make sure that the OSE/OJVM is running on the server.

    The OSE/OJVM requires an Oracle Shared Server configuration. If you do not normally have or use this configuration, see "Non-Shared Server Installations" for a workaround.

  2. Install a test servlet that you can access on the server. The examples in this section use an example servlet called DBSession, which is a stateful servlet. See "Examples" for the instructions on coding and installing this servlet.

  3. Be certain that you have the Oracle HTTP Server installed on an accessible system. The Oracle HTTP Server is part of the standard Oracle8i and Oracle9i Internet Application Server distributions.

  4. Configure the Oracle server listener so that it accepts incoming Oracle Net requests from Apache/mod_ose. See "tnsnames.ora" for specific information.

  5. Edit the Apache configuration file to include the mod_ose configuration file. See "Including Configuration Files in httpds.conf" for specific information.

  6. Generate or edit a mod_ose configuration file for your application. For the test application described in this chapter, the file is shown in "Example ose.conf".

  7. Start or restart the Apache server, so that the newly-changed configuration files are read by Apache.

  8. Try accessing the servlet using a Web browser.

  9. If you cannot access the servlet, see the section "Troubleshooting".

Starting mod_ose

The mod_ose module is configured into Apache by including its configuration file in the main Apache configuration file. In the mod_ose configuration file, the first line (apart from any comments) points to the location of the dynamic library that implements mod_ose, using the LoadModule directive. For example:

LoadModule ose_module     /private1/Apache/modose/bin/libjipa9i.so

Once mod_ose module is part of Apache, each daemon Apache process (httpd process) that the Apache listener starts includes mod_ose. There is no need to specifically start mod_ose. This is the normal way that Apache modules are included in the httpd processes.

See "ose.conf" for more information about the LoadModule directive.

Configuration Files

When an Apache process starts up, it reads the Apache configuration file to determine how it should run. The Apache configuration file, and additional configuration files that it includes, determine which modules are included in Apache, and thus how HTTP requests are handled: whether they are handled directly by Apache, or routed to the servlet engine for handling there.

There are two configuration files that you must set up to get Apache and mod_ose running properly: httpds.conf and ose.conf.

httpds.conf

The main Apache configuration file used by the Oracle HTTP Server is httpds.conf. Where $APACHE_HOME is the Oracle HTTP Server home directory, this file is located in

$APACHE_HOME/Apache/conf/


Note:

$APACHE_HOME on UNIX systems is normally $ORACLE_HOME/Apache. %APACHE_HOME% on Windows NT is %ORACLE_HOME%\Apache


This is the only file that Apache reads directly when it starts up. Other configuration files are read when they are included in httpds.conf, using the include directive.


Note:

The Apache configuration file that is used by the Oracle HTTP Server is httpds.conf, not httpd.conf.  


Configuring Apache and mod_ose is not dynamic. When you change a configuration file, you must restart Apache. However under Solaris there is a way to restart Apache on the fly, so that the configuration files are read but active connections are still maintained. Use the OS command

% $APACHE_HOME/bin/httpdsctl graceful

In the httpds.conf file, you need to modify or verify the following for mod_ose support.

ose.conf

The configuration file for mod_ose is ose.conf. It is located in $APACHE_HOME/modose/conf/. This file determines which Oracle listener connections are supported, and how requests to OSE are routed through the Oracle listener to the appropriate Web service, servlet context, and servlet.

The ose.conf file contains standard Apache directives, such as IfModule, LoadModule, and Location. The structure of ose.conf is the following:

LoadModule

The LoadModule directive is the first in the file. It specifies a module name, and the location of the dynamic library that implements the module. For an example, see "Example ose.conf".

IfModule

The IfModule directive includes the directives following if the module source has been compiled into Apache. The directive is <IfModule mod_ose.c>.

Location

The Location directive specifies URI components, and which handlers serve them. <Location /ose/*> specifies that any URI-path starting with /ose/ should be handled by the SetHandler directive that follows. For example:

<Location /ose/>
SetHandler aurora-server
</Location>

is a complete Location directive.

/IfModule

Terminates the IfModule directives.

The mod_ose-specific directives are:

AuroraService

Mandatory directive that specifies the connect identifier (in the listener initialization file tnsnames.ora) for all HTTP requests, except those that contain a URL-path that is specified in an AuroraLocationService directive.

This directive cannot be specified within a Location directive. It must be specified in the IfModule directive.

Use the -netservice option of the OSE session shell exportwebdomain command to generate this directive, or specify the netservice key in the input data file for the gencfg.pl Perl script.

AuroraWorkers
PerProcess

Optional directive that indicates the number of mod_ose worker threads that can be created per Apache/mod_ose process.

This directive is not meaningful for current Solaris releases of the Oracle HTTP Server, as Solaris Apache is single-threaded. On Windows NT, each Apache process can execute more than one client request at a time.

This value should be the same as the ThreadsPerChild value that is specified in the Apache configuration file. This applies only to Windows NT or Windows 2000 installations.

Use the -worker option of the OSE session shell exportwebdomain command to generate this directive, or specify the worker key in the input data file for the gencfg.pl Perl script.

AuroraLocationService

Optional directive included in the Location directive that indicates the TNS connect identifier to use for that location. Should not be used if the connect identifier is the same as the global connect identifier that is specified in the AuroraService directive.

These mod_ose-specific directives are generated in the configuration file using the session shell exportwebdomain command, or using the gencfg.pl Perl program.

Example ose.conf

Here is an example of an ose.conf file:

LoadModule ose_module     /private1/Apache/modose/bin/libjipa9i.so

#
# Apache configuration 
# Domain: /system/admin
# Context: admin
#
<IfModule mod_ose.c>

AuroraService inst1_modosetest

AuroraWorkersPerProcess 1

#
# Context for VPATH /admin/
#

<Location /admin/deploywar >
SetHandler aurora-server
</Location>

<Location /admin/error_log_viewer.htm >
SetHandler aurora-server
</Location>

<Location /admin/errors/internal >
SetHandler aurora-server
</Location>

<Location /admin/event_log_viewer.htm >
SetHandler aurora-server
</Location>

<Location /admin/http_log_viewer.htm >
SetHandler aurora-server
</Location>

<Location /admin/shell >
SetHandler aurora-server
</Location>

<Location /ose/ >
SetHandler aurora-server
</Location>

<Location /test/ >
SetHandler aurora-server
</Location>

</IfModule>
#
# End of configuration
#

oracle_apache.conf

Contains includes for Oracle-specific modules, such as mod_plsql and mod_ose. Include the ose.conf file in this file, using an absolute file path, then make sure that the Apache main configuration file httpds.conf includes oracle_apache.conf.

Including Configuration Files in httpds.conf

You can include the mod_ose configuration file ose.conf in the Apache configuration file httpds.conf directly, using the Apache Include directive. However, Oracle recommends that you add the Include for ose.conf to the configuration file oracle_apache.conf, which also includes the configuration files for other Oracle-specific Apache modules such as mod_plsql ($APACHE_HOME/modplsql/conf/plsql.conf). The oracle_apache.conf file is located in $APACHE_HOME/Apache/conf/. Then include oracle_apache.conf in the httpds.conf file.

Always specify the files to be included using absolute paths to the files, as Apache cannot recognize relative paths. Also, do not use operating system environment variables, such as the UNIX shell variable $APACHE_HOME, or the Windows NT environment variable %APACHE_HOME% in the Include directive.

Oracle Net and Oracle Listener Configuration

Connections from Apache/mod_ose to the OSE use the Oracle Net protocol, the same as OCI or Forms client/server applications. mod_ose uses the same mechanism for finding connection descriptors as other Oracle clients, such as OCI clients. Depending on the configuration determined by the sqlnet.ora file, connections are defined either by

See the Oracle Net Administration Guide for more information about configuration of listeners and dispatchers for the Oracle server.

So to use mod_ose with the OSE/OJVM you must at least configure the Oracle listener's initialization file: tnsnames.ora, to include connect descriptors for the connections to the OSE server. You can find specific information about doing this in "tnsnames.ora".

Generating a Configuration File

The ose.conf file contains Apache configuration commands and directives, such as LoadModule, <IfModule>, and <Location>. To create a configuration file, you could analyze your application, find the servlet contexts that mod_ose must recognize and transfer HTTP requests to, and create the mod_ose configuration file by hand, using a text editor. Or you could modify the example files that are supplied with Oracle.

These approaches, however, are very error-prone, and are not recommended.

Oracle recommends that you create a ose.conf file using the tools supplied to generate this file. With Oracle8i, you used the exportwebdomain session shell command to create the mod_ose configuration for specific Web applications. With Oracle9i, you can still use the exportwebdomain command, or you can use the new Perl script gencfg.pl. This script takes a descriptor file as input, and generates or modifies a mod_ose configuration file. This tool is described in "gencfg.pl".

tnsnames.ora

This Oracle Net initialization file specifies the connect descriptors that are used by the Oracle listener. An example of this file is provided with all Oracle server installations, as well as with Oracle client-side installations. For a complete description of the entries in this file, see the Oracle Net Administrator's Guide. In some cases, you might have to copy the file from an example location before modifying it. For example, in an NT client configuration, copy the file from %ORACLE_HOME%\network\Admin\Sample up to %ORACLE_HOME%\network\Admin, and then modify it to add the mod_ose-specific connect identifiers.

Modify this file to add one or more connect identifiers that point to OSE services. Here is an example of a possible entry:

inst1_http = 
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)
)
(CONNECT_DATA=
(SERVICE_NAME=sales.us.acme.com)
(SERVER=shared)
(PRESENTATION=http://sales)
)
)

In this example, the connect identifier inst1_http is associated with a connect descriptor that specifies the TCP/IP protocol, a host named sales-server, and a service that listens on the Net8 port 1521. A service name, sales.us.acme.com is specified, and the presentation is HTTP. The service name is the instance name in the INIT.ORA file (there can be multiple instance names in the case of Oracle Real Application Cluster installations). You create the service (the presentation) using the createwebservice session shell command.

connect identifier

The connect identifier inst1_http is an arbitrary name. This connect identifier is generated into the ose.conf file, in the AuroraService directive, by the configuration utilities. For an example, see the section "gencfg.pl".

address

The address part of the connect descriptor specifies

connect_data

This part of the entry provides a service name, the kind of server (shared or dedicated), and the presentation. The presentation is the HTTP service that you established for your application.

Non-Shared Server Installations

The mod_ose module requires a shared server installation to run. It will not run if the database is not configured with any shared dispatchers/servers. However, some users prefer not to run with shared servers as a standard configuration. Oracle recommends the following work around to let you use Apache and mod_ose in a dedicated server environment.

In the database initialization file (INIT.ORA), create one or more dedicated dispatchers and servers with a specific service name. You can use any service name that follows the INIT.ORA conventions as long as it differs from the database service name. The following examples use "MODOSE":

dispatchers="(PROTOCOL=tcp)(SERVICE_NAME=MODOSE)"
dispatchers="(PROTOCOL=tcps)(SERVICE_NAME=MODOSE)"

The connect identifier in the tnsnames entry (tnsnames.ora file) should use this service name rather than the database service name.

inst2_http =
  (DESCRIPTION= 
(ADDRESS=(PROTOCOL=tcp)(HOST=server27)(PORT=5521))
(CONNECT_DATA=
(SERVICE_NAME=MODOSE)
(SERVER=shared)
(PRESENTATION=http://admin)
)
)

You will now have a shared dispatcher and server that will not be used by other clients--only by mod_ose.

Configuration Utilities

The Oracle9i servers support the two utilities for generating configuration files for mod_ose. They are described in the following sections.

exportwebdomain

The configuration of Web applications running on OSE is specified in the JNDI namespace on the OSE server. The session shell command exportwebdomain extracts the information about the applications installed in a Web domain and generates the corresponding configuration file.

Use the exportwebdomain command to generate the structure of a Web domain in a configuration file for mod_ose. The export utility works in two stages:

This session shell tool can be used to generate the mod_ose configuration file. exportwebdomain takes as an argument the name of the Web domain for which you want to generate a configuration. For example

exportwebdomain [options] /HRRoot 

generates a configuration file for the Web domain HRRoot, which is located at the root of the JNDI namespace in the OSE server. The options to exportwebdomain are the following:

-context

Optional parameter that specifies the name of the servlet context to support. If not specified, all contexts in the domain are configured.

-netservice

The name of the service defined in the tnsnames.ora file.

-format

The XSLT transformation type. For example -format Apache for mod_ose configurations.

-worker

Optional parameter that specifies the number of worker threads per Apache process. In the release, this option applies only to NT installations, since the current release of Solaris Apache is always single-threaded.

-nodefault

Optional parameter that indicates not to map the default context, unless indicated by the -context option.

-nodocs

Optional parameter that specifies to not forward URLs mapped into doc_root to the Servlet engine. This assumes that such static pages will be served directly by the external Web server.

gencfg.pl

gencfg.pl is a Perl program that generates or modifies configuration files for mod_ose based on an input description file. The description file contains key:value pairs in a text format. The output is generated in the file ose.conf in the same directory. If the file already exists, new material is added to it.

The Perl script provides for two modes of configuration:

The keys and possible values in webdata.cfg are:

type

Optional key. If the value is simple, use the simple mode. If this key is not provided, use the exportwebdomain mode.

netservice

Mandatory key. The Oracle Net connect name to be used in generating the AuroraService directive in the output configuration file. See "ose.conf" for more about this directive.

worker

Optional key. The number of worker threads to be used for each Apache process. Used only for NT Apache in this release. The default is 1 when not specified.

domains

Web domain for which the configuration is to be generated. Mandatory if type is exportwebdomain.

context

Optional key. The servlet context to be used for Web domain. If not provided, configuration is generated for all the contexts in that domain.

alias

The database to which the session shell should connect. Optional--if not supplied, uses the local database

nodocs

Optional key. If true, do not generate configuration for documents.

nodefault

Optional key. If true, do not generate configuration for default servlets.

An example of key:value pairs in a description file (webdata.cfg) is

netservice:inst1_http
nodocs:true
nodefault:true
workers:1
context:admin
domains:/system/admin

When gencfg.pl is executed with this input file, it generates the following ose.conf configuration file:

#
# Apache configuration 
# Domain: /system/admin
# Context: admin
#
<IfModule mod_ose.c>

AuroraService inst1_http
AuroraWorkersPerProcess 1
#
# Context for VPATH /admin/
#

<Location /admin/deploywar >
SetHandler aurora-server
</Location>

<Location /admin/error_log_viewer.htm >
SetHandler aurora-server
</Location>

<Location /admin/errors/internal >
SetHandler aurora-server
</Location>

<Location /admin/event_log_viewer.htm >
SetHandler aurora-server
</Location>

AuroraLocationService

Use this directive in the following way:

When you execute the exportwebdomain session shell command to create a mod_ose configuration file, either directly or by using the gencfg.pl Perl program, the Location directives for the configured locations will contain the AuroraLocationService directive. For example

<Location /system/admin/contexts/default/ >
  AuroraLocationService inst2_https
  SetHandler aurora-server
</Location>

<Location /HRRoot/contexts/HRService/ >
  AuroraLocationService inst3_http
  SetHandler aurora-server
</Location>


Note:

The locations specified in the AuroraLocationService directives override the location specified in the AuroraService directive of the IfModule clause. 



Note:

Even if you specify a stateless handler (aurora-stateless-server) in the SetHandler clause when specifying AuroraLocationService, the semantics are those of the stateful handler. That means that the connection is closed either after the request completes (when KeepAlive is OFF), or when the client completes (when KeepAlive is ON).  


Specifying Stateful and Stateless Handlers in ose.conf

Specify whether a request uses the stateful or the stateless connection by indicating which Apache handler to use. You indicate the handlers in Location directives in the ose.conf configuration file. For example:

SSL Configuration

mod_ose can accommodate SSL connections between Apache and the OSE/OJVM, to support SSL connections between the client and OSE/OJVM. You need the following to set up SSL service:

Oracle Net uses the service name rather than the SID that was used in earlier versions of the Oracle server.

listenerAddress

An ADDRESS_LIST (host, port, protocol) in the case of multiple Oracle Listeners on the back end (multiple nodes). This allows for load balancing and fail-over configurations, as well as the use of CMAN for connection concentration.

Read the Oracle Net Administrator's Guide for information about how to set this parameter.

serviceSpec

group of database instances: specify SERVICE_NAME
Defines a group of instances that can be used interchangeably. When there are multiple database instances, mod_ose load balances the connections between the different instances.

mod_ose guarantees stateful requests from a client are sent to the same database instance so they can be associated with the same database session.

single database instance: specify INSTANCE_NAME
Indicates an specific instance within the service group should be used.

presentationSpec

Indicates which HTTP service should be used for this connection.

<JndiServiceName> is a place holder for the name of a service in the JNDI namespace (for example, /service/ServiceName) that understands HTTP and has an Oracle Net end-point associated with it. See the session shell command, createwebservice.

Configuring mod_osso

See "Using mod_osso with mod_ose" for basic information about mod_osso. This section tells you how to configure mod_osso to work with the Oracle HTTP Server and mod_ose.


Note:

mod_osso is not available with Oracle8i Release 3. 


To Configure on the Apache Side

Before chaining mod_osso with mod_ose, you must register the Oracle HTTP Server with an Oracle Single Sign-On server. See the documentation on the Oracle HTTP Server for more information.

To use mod_osso, just protect a virtual path with mod_osso. To do this, define a Location directive in the Apache configuration file httpds.conf as follows:

<Location /<context_virtual_path>/<servlet_virtual_path/> 
AuthName "OSSO Server on machine1"
AuthType Basic
require valid-user
</Location>

Enter this Location directive in the <IfModule mod_osso.c> section of the Apache httpds.conf configuration file. For more information about this, including other required options, see the Apache documentation, and the Oracle HTTP Server Administration Guide (available with Oracle9i Internet Application Server V2).

Next, configure a virtual path to be forwarded to the OSE/OJVM. For example, add the following Location directive to the ose.conf configuration file:

<Location /<context_virtual_path>/<servlet_virtual_path/> 
SetHandler aurora-server
</Location>

Enter this in the <IfModule mod_ose.c> section of ose.conf, and use the same virtual servlet context and virtual servlet path as in the Location directive in the mod_osso.c section of httpds.conf.

To Configure on the OSE Server Side

Secure the virtual path in the OSE/OJVM with the OSSO authentication method by publishing a special OSSO realm for each Web service in the OSE/OJVM. If you plan to service requests which have been authenticated by an OSSO server, you must have an OSSO HTTP security realm published in each service root that is accessed by such a request.

Publish an OSSO Realm

Publish the special OSSO realm by using the session shell realm publish command with the -type OSSO option, as shown in the following example:

$ realm publish -w[ebservice] <serviceRoot> -type OSSO

It is not necessary to specify the realm name in the -add parameter. The realm with authentication type OSSO will always be called ossoRealm. In fact, any other name you specify in the -add parameter is ignored.


Note:

There can be at most one realm with the authentication type OSSO for each service root. 


To Remove an OSSO Realm

You can remove an OSSO realm just as any other realm. Use the session shell realm publish command with the -remove option, as shown in this example:

$ realm publish -w[ebservice] <webserviceRoot> -remove ossoRealm 

Securing a Servlet Context with the OSSO Security Servlet

You can configure OSSO authentication at the level of servlet context. As with regular HTTP security, you use the session shell realm secure command, as shown in this example:

$ realm secure -s /testRoot/contexts/mycontext -osso 

Note the special -osso flag. It tells the realm command that OSSO authentication should be enabled for this servlet context. The realm secure command binds a JNDI object called httpSecurity into the /testRoot/contexts/mycontext. You can use the session shell ls command to verify the existence of the httpSecurity servlet.

A standard realm secure command, without the -osso option, also binds an httpSecurity object into the context. The difference is in the class bound to httpSecurity. For a regular HTTP Security method, httpSecurity is bound to a servlet of class oracle.aurora.mts.http.security.HttpSecurity. In the case of OSSO authentication it is bound to oracle.aurora.mts.http.security.OSSOSecurity. You can use the session shell getproperties command to verify the class binding, as shown in

$ getproperties /testRoot/contexts/mycontext/httpSecurity

This returns:

servlet.class=SYS:oracle.aurora.mts.http.security.OSSOSecurity 

Servlet contexts are secured with the HTTP Security method by default when they are created. So if you need OSSO authentication, you must explicitly use the realm secure command with the -osso option to change the type of authentication to OSSO.


Note:

For the realm secure -osso command to succeed, you must have already created the special OSSO realm in the service root, as described in "Publish an OSSO Realm"


It is also possible to configure a servlet context for OSSO authentication when creating the servlet context using a WAR file. For more information about this, see "Authenticating with Oracle Single Sign-On".

Troubleshooting

If you have trouble connecting through mod_ose to your servlets or JSPs running in the OSE/OJVM server, you can take the following steps to find the source of the problem.

  1. Make sure that the servlet has been installed correctly on the OSE/OJVM server. Follow the troubleshooting steps in Chapter 3, "OSE Configuration and Examples". See [[need ref in that chapter]] for specific steps.

  2. Make sure that the Oracle listener is running, and has been configured properly. Be certain that the AuroraService directive in the ose.conf file specifies the correct entry in the tnsnames.ora file, and that this entry has the correct service name, service type, protocol type, and port number. See "tnsnames.ora" for more information.

    You can also use the tnsping utility to test the tnsnames.ora entry.

  3. Try stopping and restarting the Oracle listener, using the lsnrctl command.

  4. Use the lsnrctl status command to view the status of each listener port.

  5. Is the Apache server running? If it is, an OS process status command (such as ps -e under UNIX, or the TaskManager under Windows NT), should show one or more httpds processes running.

  6. Try stopping and restarting the Apache server, to make sure that your latest httpds.conf and ose.conf files have been read by Apache.

  7. If the connection is refused by the server:

    • check that the proper port was being used for the request

    • make sure that the correct host name is being used for the request

  8. If an HTTP 404 error occurs:

    • check the URL contains a virtual path string that specifies the correct servlet context

    • make sure that the URL also contains a virtual path string that specifies the correct servlet within the servlet context

    • disable, as much as possible, caching in any Web browsers being used to test HTTP content

    • if the servlet was just published, or configuration information just changed, wait for any active sessions to timeout or close all current browsers and start a completely new browser

    • make sure the doc_root specified for that service and context is valid


Go to previous page Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

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

Master Index

Feedback