Oracle DBA Tips Corner |
Oracle Servlet Engine - (OSE)
by Jeff Hunter, Sr. Database Administrator
Contents
What is Oracle Servlet Engine?
Each session (virtual Java VM) executes the following items:
OSE in Oracle 8.1.7 supports servlets 2.1 and JSPs 1.0.
OSE in Oracle 9.0.1 supports servlets 2.2 and JSPs 1.1.
OSE is no longer supported in Oracle 9.2.0.
Metalink Notes on OSE Usage and Installation
NOTE: As of Oracle9i, all users are strongly encouraged to use the
Oracle Containers for J2EE (OC4J) product for J2EE applications, rather than OSE!
Connecting to the Oracle Servlet Engine
The first of these possibilities can be useful for debugging, or for quick testing
of deployed servlets. But because it does not provide adequate scaling when multiple
clients are involved, it should never be used when developing or testing production applications.
The second possibility can serve when your application consists solely of stateful
servlets or JSPs. This, however, is true of few applications.
The third possibility is the one that Oracle recommends for all applications. Static
HTML pages and other static data are served from the Oracle HTTP Server, and requests for
dynamic content are routed through mod_ose to the OSE. To set up your application to run in
this mode, there are additional configuration steps that you must perform. For example, you
must configure the Apache mod_ose configuration file ose.conf to indicate which requests will be routed to the OSE.
It is also possible to use the Oracle HTTP Server with mod_ose to connect to OSE
applications with a server configuration that does not normally use-shared servers
NOTE: Keep in mind that since OSE has a built-in web server.
This web server allows direct access from an HTTP Client to the OSE, calling static HTML
pages in the OS file system. In the detailed explanation below, this is considered as
"Connection Type #1".
Non-Shared Server Installation
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":
What are Web Services?
What is a Web Domain?
There are two types of WebService
The Web domain identification for HTTP requests depends on OSE configuration:
Single Domain Services
This example is based on a Single Domain Service configuration.
Web Service endpoint
We have following options to connect to Oracle8i OSE using HTTP endpoints:
Configuring OSE Details
When you install the Oracle HTTP Server, you will be asked for the location
of the JDK. This is usually not within the ORACLE_HOME path. We install the JDK in
/usr/local/java for Linux and /usr/java for Solaris. All of my testing
seems with have worked with Java 2 SDK 1.4.
Here is a list of the variables and locations that will be set:
Click here
to download a simple Hello.java servlet and compile it in
any directory.
In short, this connection method makes use of the Oracle HTTP Server's JServ option
for extending the web server and running Servlets and JSPs.
Instructions on configuring a servlet zone in the Oracle HTTP Server is documented
in the article
Deploying Java Servlets and JSPs using the Oracle HTTP Server (8i or higher).
For this connection type, it is assumed that you have a Typical installation which
includes the installation of the Oracle HTTP Server (Apache). You can test your Apache webserver
by invoking it at the default port 80, 7777, 7778, or 7779.
http://<your_machine_name>:80/
NOTE: You could just point to
<Location /testing/ > to include all servlets and other files
in the servlet context.
http://<your_machine_name>:80/testing/Hello
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter
and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express,
prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate,
but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from
relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
Oracle Servlet Engine (OSE) works as a specialized Web server, designed as a scalable
servlet server inside the Oracle8i database. The servlet classes are loaded into Oracle8i
and Oracle9i (9.0.1 only), and published in a JNDI namespace inside the database. A servlet runner
handles HTTP requests, instantiates published servlets in sessions, and invokes
servlet methods.
The OSE runs in a virtual JVM inside an Oracle (database) server session. You
must be running an Oracle shared server configuration to run the Oracle JVM, and
hence to use the OSE. There are three ways that an HTTP client can access a
Servlet or JSP in the OSE:
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.
mts_dispatchers="(PROTOCOL=tcp)(SERVICE_NAME=MODOSE)"
mts_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.
INST1_HTTP.IDEVELOPMENT.INFO =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)
(HOST = wwwdb3.idevelopment.info)
(PORT = 1521)
)
)
(CONNECT_DATA =
(SERVER = SHARED)
(SERVICE_NAME = MODOSE)
(PRESENTATION = http://admin)
)
)
You will now have a shared dispatcher and server that will not be used by other
clients--only by mod_ose.
Oracle Servlet Engine serves one or more Web Services. A WebService
is the entry point of your Web Applications, and we can think of it as
virtual web server. The most important Web Service parameters are its port
and its corresponding JNDI root directory.
# sess_sh
--Session Shell--
--type "help" at the command line for help message
$ createwebservice -root /iDevWebServer iDevWebServer
While logged in via Session Shell, (sess_sh), the above example creates a Web Service
named iDevWebServer (you will
retrieve this name in the /service JNDI directory) with the JNDI root of the
service being in the /iDevWebServer directory.
A Web Domain is the contents of its corresponding Web Service. A Web domain
contains configuration information stored in an object called config, servlet
contexts, realms, logs.
The address part of the sent URL is actually ignored and the port that is used to
connect to OSE solely determines the Web Domain. If that service is a Multi-Domain
service, then the address part and server IP used to connect to the server are used
to determine which domain to use.
Multi Domain Services
This document does not explain Multi-domain service configuration.
# sess_sh
--Session Shell--
--type "help" at the command line for help message
$ createwebdomain -docroot /u01/app/oracle/oraweb /iDevWebServer
The above example creates a Web Domain stored in the /iDevWebServer JNDI directory
which should already exists as a Web Service root directory. Also, the default physical
location of all static pages (-docroot option) will be /u01/app/oracle/oraweb.
A Web Service network entity is called an endpoint and can be associated with
one or more HTTP listener or HTTP dispatcher. We need to add at least one
endpoint to this service.
Pre-configuration Tasks and Setup
Before diving into the details of configuring OSE, there are a few requirements
and installation steps that need to be taken.
Getting the Flying Pig
parallel_automatic_tuning = false
shared_pool_size = 200000000
java_pool_size = 100000000
@$ORACLE_HOME/javavm/install/initjvm.sql
$ORACLE_HOME/Apache
$ORACLE_HOME/javavm/install/init_jis.sql
mts_dispatchers="(PROTOCOL=TCP)(DISPATCHERS=4)(CONNECTIONS=250)"
SQL> GRANT JAVAUSERPRIV TO SCOTT;
At the command prompt, do the following to register endpoint for the admin service:
Configure Demo Web Service (iDevDemo) for use with the OSE
# cd $ORACLE_HOME\jis\install
# sess_sh -s jdbc:oracle:oci8:@ -u sys/change_on_install
--Session Shell--
--type "help" at the command line for help message
$ @serverendp.ssh admin 8080 9090 -register
$ exit
This Web Service will be used throughout the remaining examples.
Direct Access from HTTP Client to the OSE, calling static HTML page in OS file system (Connection Type #1)
Web Service Name : iDevDemo
Web Service Root Directory : iDevDemoRoot
# sess_sh -u sys/change_on_install -s jdbc:oracle:oci8:@
sess> createwebservice -root /iDevDemoRoot iDevDemo
sess> chown -R SCOTT /iDevDemoRoot
sess> chmod -R +rwx SCOTT /iDevDemoRoot
sess> createwebdomain -docroot /u01/app/oracle/oraweb/StaticPages /iDevDemoRoot
sess> createcontext -virtualpath /iDevDemo -docroot /u01/app/oracle/oraweb/StaticPages /iDevDemoRoot iDevDemoContext
sess> addendpoint -port 7788 -register iDevDemo iDevEndpt01
sess> chmod -R +rwx SCOTT /iDevDemoRoot
This type of configuration will allow the user to establish a connection to the
Oracle Servlet Engine (OSE) "directly" using an HTTP Client (a Web Browser) to access a static HTML
page in the OS file system. No HTTP server is required for this configuration as the
OSE uses the built-in Oracle web server. The port used in the connection will be created
by the OSE by use of an end-point. In this example, we use 7788 as the end-point.
Direct Access from HTTP Client to Servlet in the OSE (Connection Type #2)
SQL> exec dbms_java.grant_permission (\
'SCOTT', 'SYS:java.io.FilePermission', \
'/u01/app/oracle/oraweb/StaticPages/example_1.html','read');
commit;
http://wwwdb3.idevelopment.info:7788/iDevDemo/example_1.html
This type of configuration will allow the user to establish a connection to the
Oracle Servlet Engine (OSE) "directly" using an HTTP Client to access a servlet
stored in the Oracle database. No HTTP server is required for this configuration as
the OSE uses the built-in Oracle web server. The port used in the connection will be
created by the OSE by use of an end-point. In this example, we use 7788 as the end-point.
Calling Servlet in the Servlet Zone of the Oracle HTTP Server (Connection Type #3)
# javac Hello.java
# loadjava -verbose -u scott/tiger Hello.class
initialization complete
loading : Hello
creating : Hello
# sess_sh -u sys/change_on_install -s jdbc:oracle:oci8:@
--Session Shell--
--type "help" at the command line for help message
$ publishservlet -virtualpath /Hello /iDevDemoRoot/contexts/iDevDemoContext Hello SCOTT:Hello
$ chmod -R +rwx SCOTT /iDevDemoRoot
$ exit
http://wwwdb3.idevelopment.info:7788/iDevDemo/Hello
This type of configuration will allow the user to establish a connection to the Oracle
HTTP Server in order to access a servlet in the server's Servlet Zone. This
configuration makes no use of the Oracle Servlet Engine (OSE), but is essential in
setting up in order to better troubleshoot problems when trying to use mod_ose to
access the OSE.
Calling Servlet in the OSE over the Oracle HTTP Server (Connection Type #4)
This type of configuration will allow the user to establish a connection to the
Oracle HTTP Server in order to access a servlet in the Oracle Servlet Engine (OSE).
This configuration uses mod_ose through the Apache Web Server in order to access the OSE.
INST1_HTTP.IDEVELOPMENT.INFO =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)
(HOST = wwwdb3.idevelopment.info)
(PORT = 1521)
)
)
(CONNECT_DATA =
(SERVER = SHARED)
(SERVICE_NAME = MODOSE)
(PRESENTATION = http://iDevDemo)
)
)
The service name is the name of the database and the presentation is the web service
created using createwebservice -root /iDevDemoRoot iDevDemo.
# sess_sh -u sys/change_on_install -s jdbc:oracle:oci8:@
--Session Shell--
--type "help" at the command line for help message
$ addendpoint -net8 -register iDevDemo iDevDemoNet8
NOTE: This step is required when using mod_ose.
This command is using the default listener. The option -net8 specifies that the
endpoint is configured to accept requests over the Net8 protocol. We in this case are using
the default port 80. The option -register specifies that the endpoint should
always exist when the listener is started. The above example iDevDemo
is the name of the web service and iDevDemoNet8 is the name of the end point.
<Location /testing/Hello >
SetHandler aurora-server
</Location>
just before the line </IfModule>.
Monday, 23-Jan-2006 08:49:30 EST
Page Count: 16642