J2EE Applications: Maintenance and Monitoring

In this final article of a six-part series, you will learn how to deploy, maintain, and monitor J2EE applications. You’ll also review the content of all of the parts; a self-test is included at the end. It is excerpted from chapter eight of the Oracle 10g Application Server Exam Guide, written by Sam Alapati (McGraw-Hill; ISBN: 0072262710).

Deploying J2EE (EJB) Applications

EJB modules depend on deployment descriptors to specify the runtime attributes of the enterprise beans. Deployment descriptors are saved in ejb-jar.xml files. EJBs are packaged and shipped along with their deployment descriptors (contained in the ejb-jar.xml file) in a standard format, in the form of a .jar (dot jar) file. When you deploy an EJB application, the deployment tool first reads the deployment descriptors specified in the ejb-jar.xml file. From this, the deployment tool gets information about the EJB, such as the type of beans packed in the .jar file, their transaction attributes, and their access permissions.

on the job:  The ejb-jar.xml file specifies the run-time behavior of EJBs.

Using the Application Server Control to Deploy J2EE Applications

It is very easy to deploy J2EE applications through the Application Server Control. Here are the steps:

  1. Go to the OC4J home page and click the Applications tab.
  2. In the Deployed Applications section, click the Deploy EAR file.
  3. The Deploy Application Wizard—Select Application page appears next. The Deploy Application Wizard will deploy the selected EAR file and apply any configuration changes you may make. Select the J2EE application you wish to deploy by providing the name and the location of the application’s EAR file. You must also select the parent application here. Click Continue.
  4. The URL Mapping for Web Modules page is next. You map a Web module to a URL pattern on your Web site and click Next.
  5. On the Resource References Mapping page, you do the following: 

    • Select the JNDI location.
    • Select the data source.
    • Select the JNDI location.
    • For each CMP entity bean, select a data source location and the tables.
    • Click Next.
  6. On the User Manager page, select the User Manager you want to use for security. The JAZN XML User Manager provides complete security; to do this, you must set up a default realm and the jazn-data.xml file. The XML User Manager requires you to additionally configure the principals.xml file. Click Next.
  7. In the Security Role Mappings page, assign security roles to the users and groups that are part of the OC4J container.
  8. In the Publish Web Services page, click the Publish button if you want to publish and Web services has defined your application. Click Next.
  9. In the Summary page, review your selections and click Deploy.

Using dcmctl to Deploy EJBs

You can use the dcmctl deployApplication command, explained previously to show how to deploy Web application modules (WAR files), to deploy J2EE applications as well. Here’s an example:

$ dcmctl deployapplication -file /test/testEAR.ear -a testEAR -co OC4J_Test

The dcmctl deployApplication command is similar to the command you use to deploy Web applications, with the difference that you don’t have to specify the -rc option in the case of J2EE application deployment. If you use the -co (component name) option to specify a particular OC4J instance, the operation applies to only that OC4J instance within an OracleAS instance. In our example, the EAR module will be deployed to the OC4J instance named OC4J_Test. If you don’t specify the -co target option, the operation applies by default to the OC4J instance named home.

The following things happen when you execute the deployApplication command:

  1. The WAR or EAR file is copied to the server.
  2. The WAR or EAR Zip file is then expanded into runtime directories.
  3. If necessary, the context root in the httpd.conf file and the mount points in the oc4j.conf file and server.xml are modified. A new mount point is added to the oc4j. conf file to match the root context.
  4. All files are copied to the DCM repository.

Changes in Configuration Files

When you deploy applications, either by using the dcmctl utility or through the Application Server Control, several changes are made in the OC4J configuration. The following text gives a brief summary of the changes made in the main configuration files.

The application name is added to the server.xml file:

  <application name=”testapp” 
      path=”../applications/testapp.ear”
/>

The context root for your new application (testapp) is added to the default-web-site.xml file, as shown here:

  <web-app application=XXXX;testapp” name=”testapp”
      root=”/testapp”/>

The application.xml file, located in the $ORACLE_HOME/applications/testapp/META-INF/ testapp directory is modified by adding the application module definitions to it:

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

In addition, a new Oc4jMount command line is added to the oc4j.conf file to match the root context /testapp.

{mospagebreak title=Maintaining and Monitoring Applications}

The OC4J home page shows all the deployed Web and EJB modules for an OC4J instance. The same page also shows a summary of application performance statistics, such as request processing time and method execution time. You can perform various management tasks by clicking the appropriate links which are grouped under the properties, resources, and security groups.

If you want to drill down into an individual application, click the link to the relevant application on the OC4J home page to get to the OC4J Application home page. Figure 8-8 shows the OC4J Application home page. From an application’s


Figure 8-8.  The OC4J Application Home Page

home page, you can monitor the status and performance metrics in the General section, right at the top of the page.

The two important sections in the Application home page are the Web Module and EJB Modules sections, which show the status and performance details about these two types of modules. You can drill down to the home pages of the various components of the two types of modules such as servlets, JSPs, and EJBs from the Web Module and EJB Module home pages.

Deploying and Registering Web Providers

You use Web providers to provide content to OracleAS Portal. Chapter 7 explains how Web and database providers work. Deploying Web providers is similar to deploying J2EE applications, because Web providers are regular J2EE applications. Portlet developers can use EAR files to deploy Web providers to the OracleAS Middle Tier. After you deploy a Web provider, you test the deployment using the URL of the provider adapter server, as shown here:

  http://hostname:port/context_root/ providers

If your deployment is successful, you’ll see the test page. If you disable the test page, client browsers will get a "403 Forbidden" response.

All Web providers must be registered with the OracleAS Portal, using the OracleAS Portal Web user interface. Registering the providers lets OracleAS Portal know how to access the providers. The portlet developer must provide the portal administrator the necessary deployment and registration instructions.

{mospagebreak title=TWO-MINUTE DRILL}

 Introduction to J2EE

  1. J2EE is used to build and deploy Web-based applications.
  2. JTI is used by applications deployed in the OracleAS to demarcate transactions.
  3. JNDI is an independent directory service that enables Java applications to access various naming and directory services.
  4. JMS provides a standard messaging API that enables application components to pass data among themselves.
  5. RMI helps distributed applications communicate by invoking procedure calls.
  6. Data sources encapsulate database connections and help provide database connectivity to J2EE applications.
  7. The J2EE Connector Architecture (J2CA) provides a standard architecture for connecting the J2EE platform to non-Java-based enterprise systems.
  8. Servlets are small programs that run on the server and are used to enable dynamic content in Web pages and JSP documents.
  9. JavaBeans are reusable components that implement the functionality needed in J2EE applications.
  10. A J2EE container contains the framework for running EJBs, such as starting an EJB, and provides necessary support services for EJBs.
  11. Enterprise JavaBeans (EJBs) are Java components that implement business logic.
  12. Session EJBs support clients during the execution of their tasks and last for the duration of a session.
  13. Entity EJBs represent an object of data, usually of a persistent nature, such as the table rows in a database.
  14. Entity EJBs can reflect two types of persistence: container-managed persistence (CMP) and bean-managed persistence (BMP).
  15. Message-driven EJBs represent the integration between the JMS (Java Message Service) and EJBs.
  16. J2EE applications can have three types of application deployment files, also called archives: JAR files, WAR files, and EAR files.

Oracle Containers for Java

  1. OC4J is a set of containers that enable J2EE application deployment.
  2. When you create a new OracleAS instance, you automatically install a set of default OC4J instances, to support the various OracleAS components.
  3. You must use the Oracle Application Server to manage OC4J.
  4. The two command-line tools you can use to manage OC4J instances are the familiar opmnctl and dcmctl utilities.

Creating an OC4J Instance

  1. The name of the default OC4J instance is home.
  2. You can create new OC4J instances with either the dcmctl utility or the Application Server Control.
  3. The dcmctl createComponent command helps you create a new OC4J instance.
  4. The ListComponents command helps you view all OC4J components.
  5. You must start a newly created OC4J instance using the Application Server Control or the opmnctl utility.
  6. You use the destroyInstance command to clear repository information about a removed OracleAS instance.

Managing the OC4J Instance

  1. The recommended way to manage the OC4J instance is to use the Application Server Control.
  2. To start or stop a single OC4J instance, use the opmnctl command with the ias-component option.
  3. To start or stop all the OC4J instances in an OracleAS instance, use the opmnctl command with the process-type option.
  4. Every OC4J instance has a separate OC4J home page in the Application Server Control Console.
  5. You can start and stop an OC4J instance either from the Application Server Control home page or from the OC4J home page.
  6. You can edit the server.xml file either by using the Server Properties link on the Administration page or by clicking the Advanced Properties link.
  7. The Website Properties home page lets you specify which Web applications are loaded when you start an OC4J instance.
  8. You can deploy a .ear file to a single OC4J instance or to all OC4J instances in a cluster.
  9. You can’t directly redeploy an application; you must first undeploy and then deploy the application again.
  10. You use the dcmctl updateConfig command to let the OracleAS instance know that you have manually updated the configuration files using the standalone tool admin.jar.

Configuring OC4J

  • An OC4J instance has three types of
    configuration files: mod_oc4j files, server
    configuration files, and application deployment files. 
  • The default port for the Oracle Web Cache on a UNIX system is 7777. 
  • The mod_oc4j module facilitates communication between the Oracle HTTP Server and the OC4J instance. 
  • The mod_oc4j module helps to provide transparent failover for clustered OracleAS instances. 
  • The server.xml file is the key OC4J server
    configuration file. 
  • The server.xml contains references to other
    configuration files, including J2EE configuration
    files. 
  • The server.xml, application.xml, and the default-web-site.xml files together define an application’s configuration. 
  • The default-web-site.xml file contains the default Web site configuration details. 
  • The jazn.xml and jazn-data.xml files are used for security configuration, if you’re using the Java Authentication and Authorization Service (JAAS). 
  •  Logical data source objects are published in the JNDI tree. 
  • Applications retrieve database connections through the java.sql.DataSource objects and look up the objects through the JNDI. 
  • The java.sql.DataSource object specifies the properties and methods of the data source objects. 
  • You use the data-sources.xml file to configure the OC4J database sources used by various applications.
  • An application can also specify data sources at the application level, using the <data-sources> tag in the application.xml file.
  • Each application has a separate JNDI namespace.
  • Managed data sources are directly managed by OC4J, whereas native data sources are provided by vendors and implement the java.sql.dataSource interface but aren’t wrapped by OC4J.
  • The principals.xml file contains user, group, and other security-related information.
  • Web application modules are contained in WAR files and include servlets and JSP pages.
  • EJB applications are contained in EAR files and include EJBs.
  • Client applications (JSPs) are contained in JAR files.
  • To deploy an application to OC4J, you archive the JAR and WAR files into an EAR file.
  • Each J2EE application type has two types of OC4J application configuration files: an OC4J specific file (Orion files) and a J2EE deployment descriptor file.
  • If you don’t explicitly create the OC4J-specific deployment file, they’ll be automatically created at deployment time.
  • The J2EE application.xml file is the global configuration file for all applications.
  • Each application has its own local application.xml file.
  • The orion-application.xml file is the OC4J-specific global configuration file for all applications.
  • The autocreate-tables and autodelete-tables attributes determine whether to automatically create and delete tables for CMP beans.
  • You must set autocreate-tables to false if you want to bind EJBs to existing tables.
  • The orion-ejb-jar.xml file contains the mapping of EJBs to the OC4J server environment.

The OC4J Server Configuration Files

  • The OC4J server configuration files help configure the OC4J server.
  • The configuration settings in the OC4J configuration files apply directly to the OC4J server and not to the deployed J2EE applications.
  • The server.xml file is the key OC4J server configuration file; it contains references to most of the files used by the OC4J server.
  • The jazn-data.xml and the jazn.xml files are used for security configuration if you’re using the Java Authentication and Authorization (JAAS) Service.
  • The data-sources.xml file lets you configure OC4J database sources used by the various applications hosted by the OC4J instance.
  • The principals.xml file contains user and group information as well as permissions and certificates.
  • The rmi.xml file contains Remote Method Invocation (RMI) configuration information.
  • The jms.xml file contains the OC4J Java Messaging Service (JMS) implementation configuration information.
  • The web-site.xml file contains Web site configuration information.
  • There are two basic types of application configuration XML files: J2EE deployment (configuration) files and an OC4J-specific configuration file.
  • There are four J2EE application types: EJB, Servlet (Web Modules), JSP, and Client.
  • Each J2EE application has a J2EE deployment descriptor XML file and an OC4J-specific deployment descriptor XML file.
  • In addition to the different J2EE deployment XML files, there is also a set of four common global configuration files for all types of applications.

Deploying J2EE Applications

  1. Application directory naming conventions must be consistent with the appropriate directory structure for creating necessary JAR, WAR, and EAR files.
  2. You can deploy applications through dcmctl or the Application Server Control.
  3. You can also deploy applications by manually editing the configuration files and if you do so, you must run the dcmctl updateconfig command to record, in the Metadata Repository, the changes you made.
  4. When you are specifying JNDI locations as part of a data source creation, you must specify the XA and EJB locations only if you plan on having the EJBs use the database for CMP. Otherwise, specify only the Location attribute.
  5. The default data source (OracleDS) is emulated, which means you can connect only to a specific database.
  6. You must use a non-emulated data source if the application must access multiple databases.
  7. When you deploy a WAR file for the first time, it’s wrapped inside an EAR file.
  8. EJB deployment descriptors are saved in the ejb-jar.xml files.
  9. Web providers are regular J2EE applications.
  10. All Web providers must be registered with the OracleAS Portal, using the OracleAS Portal Web user interface.

{mospagebreak title=SELF TEST}

  1. What is the name of the default OC4J instance?

    A. Home

    B. Default OC4J

    C. OC4J Home

    D. OC4J
  2. Which two of the following statements are true, regarding a data source for a J2EE application?

    A. For an emulated data source, you must specify only the ejb-location attribute to look up the data source in the JNDI space.

    B. For a non-emulated data source, you must specify only the value for the location attribute to look up the data source in the JNDI space.

    C. For an emulated data source, you must specify the location, the xa-location, and the ejb-location attributes to look up the data source in the JNDI space.

    D. For a non-emulated data source, you must specify the location, the xa-location, and the ejb-location attributes to look up the data source in the JNDI space.
  3. Which of the following opmnctl commands would you use to start all the OC4J instances?

    A. $ opmnctl startproc ias-component=OC4J_HOME

    B. $ opmnctl startproc process-type=OC4J_HOME

    C. $ opmnctl startproc process-type=OC4J

    D. $ opmnctl startproc ias-component=OC4J
  4. Which of the following is the main OC4J configuration file?

    A. server.xml

    B. web.xml

    C. oc4j_module

    D. application.xml
  5. Which of the following would you use to deploy J2EE applications?

    A. A WAR file

    B. An EAR file

    C. A JAR file

    D. An APP file 
  6. What is the mod_oc4j?

    A. A key configuration file that facilitates communication between the Oracle HTTP Server and the OC4J instance.

    B. A key configuration file that helps configure the Web server.

    C. A module that’s a part of the HTTP server and facilitates communication between the HTTP server and the OC4J instance.

    D. A module that’s a part of the HTTP server that determines the OC4J configuration settings.
  7. Where are data sources published?

    A. Java Naming and Directory Interface

    B. Java.sql.dataSource object

    C. httpd.conf file

    D. server.xml file 
  8. Which of the following is the OC4J-specific global configuration file?

    A. orion-application.xml

    B. server.xml

    C. application.xml

    D. global-application.xml 
  9. What happens when you deploy a Web application for the first time?

    A. Its EAR file is wrapped into a JAR file.

    B. Its JAR file is wrapped into a WAR file.

    C. Its WAR file is wrapped into a JAR file.

    D. Its WAR file is wrapped into an EAR file. 
  10. Which of the following must you do to connect an application to multiple databases?

    A. You must use an emulated data source.

    B. You must use a non-emulated data source.

    C. You must use the default data source.

    D. You must not use the data-sources file at all.
{mospagebreak title=SELF TEST ANSWERS}
  1. A is correct. The default OC4J instance is named home. 
    B, C, and D are wrong because there are no such default OC4J instances.
  2. B and C are correct. B is correct because you must only specify the location attribute when looking up a non-emulated data source in the JNDI tree. C is correct because you must specify all three attributes for emulated data sources, although only the ejb-location attribute is used by the applications, servlets, JSPs, and EJBs. 
    A is wrong because you must specify all three attributes for emulated data sources, and D is wrong because you must specify only the location attribute for a non-emulated data source.
  3. C is correct. The opmnctl startproc process-type=OC4J command will start all OC4J instances in an OracleAS instance. 
    A is wrong because the ias-component option starts only the specified OC4J instance, not all OC4J instances. B is wrong because the process-type option can’t be used to start a single instance of OC4J. C is wrong because the command is missing the process-type option.
     
  4. A is correct. The server.xml file is the main OC4J configuration file. 
    B is wrong because the web.xml file contains the Web configuration information. C is wrong because the oc4j_module is part of the Oracle HTTP Server configuration, not the OC4J configuration. D is wrong because the application.xml is the key configuration file for an application, not the OC4J instance. 
  5. B is correct. You use EAR files to deploy J2EE applications. 
    A is wrong because WAR files are used to deploy Web applications, not J2EE applications. C is wrong because JAR files are used to deploy client applications only. D is wrong because it refers to a nonexistent type of file. 
  6. C is correct. The mod_oc4j module is part of the Oracle HTTP Server, and it is instrumental in facilitating communications between the Web server and the OC4J instance.
    A and B are wrong because the oc4j_module isn’t a configuration file but an HTTP module. D is wrong because the oc4j_module has nothing to do with the OC4J configuration. 
  7. A is correct. Data sources are published in the Java Naming and Directory Interface ( JNDI).
    B, C, and D are the wrong locations for publishing the data sources. 
  8. A is correct. The OC4J-specific global configuration file is named orion-application.xml (all OC4J-specific files have the orion prefix in the XML files).
    B is wrong because the server.xml file is the main configuration file for the OC4J instance. C is wrong because the application.xml file is the main J2EE-specific application configuration file. D is wrong because it refers to a nonexistent configuration file.
  9. D is correct. When you deploy a Web application for the first time, its WAR file is wrapped into an EAR file.
    A, B, and C are wrong because they provide the wrong filenames.
  10. B is correct. You must use a non-emulated data source to access multiple databases.
    A is wrong because an emulated data source will let you connect only to a single database instance. C is wrong because the default data source (OracleDS) is an emulated data source that allows you to connect to just a single Oracle database. D is wrong because you must use a datasource file when you’re using data sources.
[gp-comments width="770" linklove="off" ]

chat sex hikayeleri Ensest hikaye