• Non ci sono risultati.

Building and Deploying Within a Directory

Nel documento Oracle9AS Containers for J2EE (pagine 98-103)

2. Modify thej2ee/ context to your desired context. In our example, you would have another line with apubs/ mount configuration. Assuming that the OC4J worker name isOC4Jworker, then both lines would be as follows:

Oc4jMount /j2ee/* OC4Jworker Oc4jMount /pubs/* OC4Jworker

3. Restart the Oracle HTTP Server to pick up the new mount point.

Then all incoming requests for thepubs/ context will be directed to the OC4J server. Note that when you deploy an application using the deployment wizard, the wizard automatically adds a mount point as described here for your URL mapping.

See the Oracle HTTP Server Administration Guide for complete details on the mod_oc4j module configuration.

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 3–10, changes. This is the directory that server.xml knows as the "master"

location. Normally, you develop under thej2ee/home/applications directory.

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 3–10 displays the necessary directory structure.

Note: The OC4Jworker is defined further down in the mod_oc4j.conf file to be the OC4J instance.

Building and Deploying Within a Directory

Figure 3–10 Development Application Directory Structure

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

1. Place the files in any directory.Figure 3–10 demonstrates an application placed intoj2ee/home/applications/<appname>/. The directory structure below

<appname> is similar to that used within an EAR file, as follows:

a. 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 3–10 demonstrates these directory names by<ejb_module>/,<web_module>/,

<client_module>/, and<connector_module>/.

applications/<appname>/

META-INF/

application.xml

<ejb_module>

EJB classes (my.ejb.class maps to /my/ejb/class) META-INF/

Building and Deploying Within a Directory

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

2. Modify theserver.xml,applications.xml, and*-web-site.xml files as follows:

Inserver.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. InFigure 3–10, 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 inFigure 3–10, 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 inFigure 3–10, if<appname> is"myapp", then the rela-tive path is as follows:

<application_name="myapp" path="../myapp" auto-start="true"

/>

Inapplication.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 theapplication.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 theWEB-INF orMETA-INF directories in each of these

application types.

For example, if the<web_module>/ directory inFigure 3–10 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>

Building and Deploying Within a Directory

</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 theserver.xml file. Thename 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 theapplication.xml file.

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

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

/>

Note: You achieve better performance if you are deploying with a JAR file. During execution, the entire JAR file is loaded into

memory and indexed. This is faster than reading in each class from the development directory when necessary.

Building and Deploying Within a Directory

4

Nel documento Oracle9AS Containers for J2EE (pagine 98-103)