9. Deploying a JSP Application

Exercise Objectives

The objective of this session is to deploy a simple BI Beans JSP application to a server with a JSP engine.

Exercise Description

After development, the application should be deployed to a J2EE-compliant production server. To accomplish this, set up the server and deploy directly from the JDeveloper environment.

Several web servers contain JSP and servlet support to run BI Thin Beans including Oracle Application Server 10g Containers for J2EE (OC4J), Oracle Application Server Apache/JServ, Oracle Servlet Engine (OSE), Jakarta Tomcat, Sun iPlanet, BEA WebLogic Enterprise, IBM WebSphere, Allaire JRun, and so on. Oracle Application Server Apache/JServ is based on the Apache/JServ engine, which complies with Java Servlet Specification 2.0, while the other web servers that were mentioned comply with Java Servlet Specification 2.2. For more information about J2EE application deployment, refer to the JDeveloper Help topics on packaging and deploying.

This exercise will demonstrate deployment to a standalone OC4J server. Ensure that JDK 1.3.1 and OC4J are installed on your production machine. The JDK home directory will be referred to as <jdk_home> and the OC4J home directory will be referred to as <oc4j_home>.

Exercise Tasks

Deploy the application

OC4J supports all types of J2EE applications: Web applications that contain servlets and JSPs and Enterprise JavaBeans applications that contain JavaBeans. The following ways are available to deploy J2EE applications:

Deployment to an exploded directory requires direct access to the Web server directory tree. Therefore, this approach is better for the development cycle than for production deployment.

For best results, package WAR files and EJB JARs into a standard J2EE-compliant Enterprise Application Archive file with the .ear extension. A Web Application Archive file with the .war extension is a single file that contains all of the components of a web application. An EAR file can contain several EJB jars or WAR files.

To deploy the application to an OC4J server, you must perform the following tasks:

To restart the OC4J server

Stop the OC4J server. Open a command prompt on the server machine, ensure that the JDK binaries (that is, <jdk_home>/bin) are in the path, and use the following command under <oc4j_home> on the production machine:

java -jar oc4j.jar

If you are deploying to OC4J within Oracle Application Server, refer to the JDeveloper Help system for special instructions about how to restart OC4J within Oracle Application Server.

To specify connection information to the OC4J server

In JDeveloper, to facilitate the deployment process, specify the connection information to the OC4J server. The following steps are required only the first time that you deploy a web application to OC4J from JDeveloper.

  1. In the System-Navigator pane in JDeveloper, expand the Connections node.
  2. Right-click Application Servers and select New Connection. Choose Next to continue.
  3. In the Connection name box, enter deployConn and select Standalone OC4J in the Connection type list box. Choose Next to continue.
  4. Enter the administrator's user name and password to access OC4J and choose Next. Note that the username and password are <admin-username> and <admin-password> respectively.
  5. In the URL box, enter the hostname of the OC4J server machine. For example, ormi://www.server.com/.
  6. In the Local directory where admin.jar for OC4J is installed box, accept the default and choose Next.
  7. Choose Test connection. If the connection test is successful, then choose Next to continue; otherwise, return to previous steps to fix the configuration settings.
  8. Choose Finish.

To deploy objects to the remote BI Beans Catalog

Before you deploy your application, copy your objects to the BI Beans Catalog, which is a persistent database. For directions, follow the tutorial Copying Objects to the BI Beans Catalog to copy the objects. After the objects are copied, the runtime settings for the application are updated automatically to use the objects in the Catalog at runtime.

To create a deployment profile for the application

  1. In the System-Navigator, select Project1.jpr.
  2. From the File menu, choose New to create a new JDeveloper object within that project. The JDeveloper New Wizard appears.
  3. Select the category General, then Deployment Profiles.
  4. Select the item WAR file - J2EE Web Module and then choose OK. The Save Deployment Profile Wizard appears.
  5. In the deployment profile file name box, enter webapp.deploy and choose Save.
  6. Choose General under the profile settings, and check the Specify J2EE Web Context Root checkbox.
  7. Enter webapp as the web context root and then choose OK.
  8. From the File menu, choose Save All to save the application.

You have successfully created a new deployment profile named webapp.deploy.

To deploy the application to OC4J server

Right-click the deployment profile webapp.deploy under Project1.jpr and choose Deploy to deployConn (that is, the connection name that you specified earlier).

The JDeveloper deployment wizard creates the files webapp.war and webapp.ear under the project folder, copies these files to the OC4J applications directory, and invokes the Oracle Application Server administration tools to configure the application (that is, to unpack the EAR and WAR files and edit the XML configuration files within OC4J).

To create a deployment profile for the required libraries

  1. In the System-Navigator, select Project1.jpr.
  2. From the File menu, choose New to create a new JDeveloper object within that project. The JDeveloper New Wizard appears.
  3. Select the category General, then Deployment Profiles.
  4. Select the item JAR File - Simple Archive and then choose OK. The Save Deployment Profile Wizard appears.
  5. In the deployment profile file name box, enter bibeans.deploy and choose Save.
  6. Choose Files under the profile settings and uncheck Project1.jpr, which unchecks all files .
  7. Under JAR Options, check Compress Archive.
  8. Under Dependency Analyzer, select BI Beans Runtime, BC4J Runtime, UIX Runtime and OLAP API 92. Choose OK to complete the definition of the profile.
  9. From the File menu, choose Save All to save the application.

You have successfully created a new deployment profile named bibeans.deploy.

To deploy the libraries to the OC4J server

  1. In the System-Navigator, right-click the deployment profile bibeans.deploy under Project1.jpr and choose Deploy to.
  2. Use the default filename of bibeans.jar and choose Save.
  3. In the Deployment Log, note the location of bibeans.jar.
  4. On the server machine, create a new directory named lib under <oc4j_home>/applications/webapp/webapp/WEB-INF.
  5. Copy bibeans.jar from the machine that is running JDeveloper to the server machine under the newly-created libraries directory <oc4j_home>/applications/webapp/webapp/WEB-INF/lib. These libraries will be appended automatically to the application CLASSPATH at runtime.

Start and run the application

To run the application

You can access the web application in a browser by entering its application URL,
http://host-name:port-number/virtual-path/filename, where:

For example:

http://myMachine.oracle.com:8888/webapp/simpleJSP.jsp

To reset runtime settings within JDeveloper after deployment

After deployment, you may want to reset the JDeveloper runtime settings so that the application will reference objects locally during development.

  1. In the System-Navigator pane, right-click the BI Configuration file (for example, Project1BIConfig1.xml) and choose Settings.
  2. In the BI Beans Settings dialog box, select the Use design settings check box and choose OK.

Exercise Summary

You have successfully deployed a simple JSP application from JDeveloper.

8. Adding "Print" Functionality | Overview