Oracle9i Application Server Administrator's Guide Release 2 (9.0.2) Part Number A92171-02 |
|
Oracle9iAS Containers for J2EE (OC4J) provides a complete set of Java 2 Enterprise Edition containers that allow you to deploy all types of J2EE applications. This chapter provides an introduction to deploying J2EE applications to OC4J using the Enterprise Manager Web site and uses the familiar Petstore demo as an example of deploying an application.
It contains the following topics:
For complete information on deploying applications to OC4J, refer to Oracle9iAS Containers for J2EE User's Guide
See Also:
You can deploy J2EE applications using the OC4J Home Page on the Enterprise Manager Web site. To navigate to an OC4J Home Page, do the following:
Figure 8-1 shows the Deployed Applications section. In this section, you can deploy applications using the Deploy EAR file or Deploy WAR file buttons. After deployment, you can modify the configuration of each application.
An application may require service configuration, such as data sources or security. This chapter does not cover such configuration. See Oracle9iAS Containers for J2EE User's Guide or Oracle9iAS Containers for J2EE Services Guide for more information. The Deploying the Petstore Web Application Demo section provides an example of how you can configure data sources to support the application. In addition, the Oracle9iAS Containers for J2EE User's Guide provides more information on creating EAR and WAR files.
Clicking Deploy EAR File or Deploy WAR File starts the deployment wizard, which deploys the application to the OC4J instance and binds any Web application to a URL context.
Note:
You can also deploy simple applications with |
Your J2EE application can contain the following modules:
The Web applications module (WAR files) includes servlets and JSP pages.
The EJB applications module (EJB JAR files) includes Enterprise JavaBeans (EJBs).
Archive the JAR and WAR files that belong to an enterprise Java application into an EAR file for deployment to OC4J. The J2EE specifications define the layout for an EAR file.
The internal layout of an EAR file should be as follows:
Text description of the illustration deploya.gif
Archive these files using the JAR command in the <appname>
directory, as follows:
% jar cvfM <appname>.EAR .
Note that the application.xml
file acts as a manifest file.
Both of these buttons start an eight-step application deployment wizard that guides you through deploying an application. When you deploy an application within a WAR file, the application.xml
file is created for the Web application. When you deploy an application within an EAR file, you must create the application.xml
file within the EAR file. Thus, deploying a WAR file is an easier method for deploying a Web application.
Note: You must still provide configuration for J2EE services, such as data source and security configuration. |
Figure 8-3 shows the eight steps required for application deployment:
The first page is an introduction to these steps. It reminds you to provide an EAR file with any OC4J-specific XML configuration files, if necessary. It also outlines some of the other steps in the deployment process.
Click Next to go to the next step in the wizard deployment process.
Figure 8-4 shows the second page, which enables you to browse your system for the EAR file to be deployed and provide a name to be identified with this application. The application name is user-created and will be the identifier for the application in the OC4J Home Page.
When the application is deployed, the following occurs:
/applications
directory.
server.xml
for the application, as follows:
<application name=<app_name> path=<path_EARfile> auto-start="true"
/>
where
name
variable is the name of the application you provided.
path
indicates the directory and filename where the EAR file is deployed.
auto-start
variable indicates whether this application should be automatically restarted each time OC4J is restarted.
For a description of the elements in server.xml
, see Oracle9iAS Containers for J2EE User's Guide.
Click Next to go to the next step in the wizard deployment process.
Map any Web modules in your application to a specific URL for its servlet context. All OC4J servlet contexts must be prefixed with a slash "/
". When you try to access any Web applications, you provide the host, port, and Web context.
For all Web modules, your URL mapping for the module includes the URL you bind in this screen. Thus, for the URL http://
host
:
port
/url_name
, provide /url_name
in the URL mapping screen of the wizard.
Click Next to go to the next step in the wizard deployment process.
Map any resource references in your application, such as data sources or mail queues, to physical entities currently present on the OC4J container. Note that if you need a specific resource, you must have already added it to the OC4J container before you deploy your application in order for you to match them in this step.
For most applications, the resource reference you must designate is the data source JNDI name. This screen does not configure the data source information, it only designates an already configured data source or a data source that you will be configuring later. Designate the JNDI location name of the data source that the application uses.
Click Next to go to the next step in the wizard deployment process.
You can specify what User Manager to use for security. For complete security, we recommend that you choose the JAZN XML User Manager.
As Figure 8-7 demonstrates, you must already have your User Manager set up and configured. Most of the entries require an XML file that designates the security roles, users, and groups for your security mappings.
The User Manager types are as follows:
jazn-data.xml
file.
principal.xml
file.
For more information on security and User Managers, see both the Oracle9iAS Containers for J2EE User's Guide and the Security chapters in the Oracle9iAS Containers for J2EE Services Guide.
Map any security roles defined in your application to existing users and groups. If you have defined a security role within your application, you can map this role to a security group or role. You do not define security groups and users in this screen. Users and groups are obtained from your user manager.
Click Next to go to the next step in the wizard deployment process.
Publish any Web services defined in your application. This feature requires the UDDI registry. Web services are not installed with a core install.
If you have defined any Web services, they are displayed on the Publish Web Services Page.
If you want to publish these Web services, then click Publish. This leads you through the process of publishing your Web services. When finished, it brings you back to this screen.
Click Next to go to the next step in the wizard deployment process.
At this point, you will receive a summary of your application deployment modules and configuration, as shown in Figure 8-10.
In order to deploy this application, click Deploy. The wizard displays a message that tells you that your application is deployed.
You can modify any fields and perform additional configuration tasks by returning to the OC4J Home Page and selecting the application name in the Applications section. This brings you to a screen with the details of the deployed application.
From within this screen, you can view the Web and EJB modules. In addition, you can add and modify application-specific properties, resources, and security options in the Administration section. It is in this Administration section that you can add application-specific data sources or security groups or users mentioned in the deployment wizard.
This section uses the Petstore demo as an example of how to configure and deploy a J2EE application. All OC4J server configuration and modifications to the Petstore application configuration have been performed for you. You can execute the Petstore demo with minimal effort to see how OC4J works.
Note: Displays of the screens for each step of the deployment wizard are shown in "Deploying J2EE Applications". |
This section contains instructions for downloading and deploying an OC4J-ready version of the Petstore demo. You must have a working Oracle database and an OC4J installation. You should use this installation for demonstration purposes only and not in a production environment. In this simplified version, we have pre-built the Petstore demo using Oracle database (instead of the default Cloudscape) and edited the configuration files to make the setup easy.
The Petstore demo is available on Oracle Technology Network (OTN). To install, configure, and run the Petstore demo:
http://otn.oracle.com/sample_code/tech/java/oc4j/content.html
and find the Petstore Demo in the Sample Code section.
jps112.zip
file, which contains version 1.1.2 of the Petstore demo. This ZIP file contains an annotated version of this application, along with preconfigured OC4J XML files.
jps112.zip
file, which contains the following:
steps.html
--Steps on how to deploy the Petstore demo in standalone mode. This HTML file does not contain directions on how to deploy using the Oracle Enterprise Manager. The steps in this book instruct you on how to deploy using Enterprise Manager.
petstore.ear
--The Petstore demo is contained in petstore.ear
.
config.zip
--OC4J server XML configuration files are provided for you in config.zip
file.
config.zip
file to retrieve the server.xml
, default-web-site.xml
, and data-sources.xml
files.
data-sources.xml
to point to your database by replacing the host, port, and sid in the url
attribute for the database as follows:
url="jdbc:oracle:thin:@host:port:sid"
estoreuser
in your database and grant this user privileges to connect as SYSDBA
to your database. You can create the user and grant privileges through the following command:
SQL> grant connect, resource to estoreuser identified by estore;
Since the data sources are provided in a data-sources.xml
file, add these data sources using the XML editor within Enterprise Manager. Select data-sources.xml
in the filename column. This brings up a screen with XML in a text window. Merge the data sources from the data-sources.xml
that was provided within the config.zip
of the Petstore download into the file in this window. Do not overwrite other data sources already configured in this file. When finished, click Apply.
petstore.ear
file that you downloaded to your system. Type "petstore
" in the application name field. Click Next.
/estore
servlet context. Type "/estore
" in the URL mapping field and click Next.
petstore
" in the Name column of the Applications section on the OC4J Home Page. This shows the configuration and all deployed modules of the Petstore demo application. If the OC4J server is started, the application is automatically started.
http://http_server_host:http_server_port/estore
The Petstore splash screen appears. Follow the instructions provided by the Petstore application to load the Java Petstore database tables.
If the deployment process is interrupted for any reason, you may need to clean up the temp directory, which by default is:
The deployment wizard uses 20 MB of swap space in the temp directory for storing information during the deployment process. At completion, the deployment wizard cleans up the temp directory by removing its files. However, if the wizard is interrupted, it may not have the time or opportunity to clean up the temp directory. Thus, you must clean up any additional deployment files from this directory yourself. If you do not, this directory may fill up, which will disable any further deployment. If you receive an Out of Memory
error, check for space available in the temp directory.
If the temp directory does not have enough space, you can configure OC4J to use a different temp directory using the Enterprise Manager Web site:
java.io.tmpdir=new_temp_dir
where new_temp_dir
is the full path to the new temporary directory.
All new OC4J processes will use the new temp directory.
You can undeploy a J2EE Web application using the Enterprise Manager Web site:
This operation results in the following:
You can also undeploy applications with
Note:
dcmctl
, the DCM command-line utility. See Appendix F, "DCM Command-Line Utility (dcmctl)" for directions.
|
Copyright © 2002 Oracle Corporation. All Rights Reserved. |
|