Archive

Posts Tagged ‘WebLogic’

WebLogic Server and APEX

September 15, 2008 7 comments

A good friend and colleague of mine at Oracle, Mark Greynolds, shared with me his work with WebLogic and APEX and getting them to work together. I thought it was something that everyone would be interested in and asked him if he would be willing to document the steps and allow me to post them here on my blog. He was and so here it is.

WebLogic Server and APEX

When a WebLogic Server (WLS) is the primary Web server, accessing APEX pages though the WLS requires a proxy. The configuration of APEX generally follows one of two configurations – Apache with mod_plsql or the Embedded PL/SQL gateway. When WebLogic (without Apache) is the main HTTP server, getting APEX to surface on the same port as WebLogic requires some form of proxy.

Overall Approach

This solution creates a very simple Web Application that invokes a Java Proxy Servlet when a user tries to access APEX pages. Wrapping this Web Application around the Java Proxy Servlet lets the WLS serve APEX without any port conflicts. The WLS Proxy Servlet is a fully documented out of the box tool. To create and deploy the Web Application simply build the files outlined in this document, deploy the application and then access APEX.

Exploded deployment

For convenience, this solution takes advantage of the exploded deployment feature of the WSL. In addition to the ability to deploy jar, war and ear files, the WLS can deploy Web Applications as an exploded directory that contains the same contents of the archive file. An exploded archive directory contains the same files and directories as a jar archive. However, the files and directories reside directly in the file system instead of as a single archive file (JAR). This example uses the exploded deployment style to create the Web Application for this example.

Default WebLogic application

The default Web Application is what the server sends to browser clients who do not specify a recognized URI (or specify only “/” as the URI). Each server has only one default Web Application and for this solution to work, this application must be set as the default. If there is already a default, this servlet could be added to the existing application by using an exploded deployment of the default with modification to the web.xml to register the APEX proxy.

Pre-requisites

1. An Oracle database successfully serving APEX pages. The APEX instance may be on the same or different machine and served from either Apache or the Embedded PL/SQL gateway. In this example, APEX uses the Embedded PL/SQL Gateway of a database running on the same machine as the WebLogic server and natively appears at the http://localhost:8080/apex URL.

2. An Oracle WebLogic Server 10.3 running a Node Manger, the Administration Console and a Managed server. This example uses a domain created specifically for this exercise named APEXDemo. The WLS Administration console uses port 7001 and the Managed Server uses port 80.

3. There is no other “default” WebLogic application for the Managed Server.

Create the APEX Proxy Servlet

1. Create the following directory structure somewhere on disk. This example assumes the C:\ drive is used. Note: the apexproxy.war directory name mimics the normal J2EE naming convention for Web Application archive (WAR).

2. In the apexproxy.war directory, create the index.html file. The WLS Managed Server renders this page when the server cannot map the browser’s URL to a valid destination. For this example, APEX becomes the default page due to a simple redirect to the full APEX path.


<html>
  <head>
    <meta http-equiv="refresh" content="0;url=apex">
  </head>
  <body>
  </body>
</html>

3. In the WEB-INF directory, create the web.xml file that defines this simple Web Application.

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
  <display-name>APEX Proxy</display-name>
  <servlet>
    <servlet-name>ProxyServlet</servlet-name>
    <servlet-class>
        weblogic.servlet.proxy.HttpProxyServlet
    </servlet-class>
    <init-param>
<param-name>redirectURL</param-name>
<param-value>http://localhost:8080</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
     <servlet-name>ProxyServlet</servlet-name>
     <url-pattern>/apex/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
  <servlet-name>ProxyServlet</servlet-name>
    <url-pattern>/i/*</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
      <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>

The <servlet-class> tag identifies the proxy servlet class and provides the
redirection URL to use when the container invokes the servlet. The two
<servlet-mapping> tags explicitly identify the two URL patterns used by APEX.
The WLS documentation suggests using a single mapping of “/” but this causes every
unmatched request to forward to the Oracle XML DB default splash page and ignores the
index.html file.
4. In the WEB-INF directory, also create the following weblogic.xml file. At deployment, WLS scans this file for the information on how to configure the deployment.

<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app
 xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app
                     http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
  <session-descriptor></session-descriptor>
  <jsp-descriptor></jsp-descriptor>
  <container-descriptor></container-descriptor>
  <context-root>/</context-root>
  <servlet-descriptor>
    <servlet-name>ProxyServlet</servlet-name>
  </servlet-descriptor>
</weblogic-web-app>

The <context-root> tag is the key for making this example function. This tag
makes this the default application for the Managed Server.

Deploy the Proxy Servlet

5. Begin the deployment by accessing the WLS Administration Console using the http://localhost:7001/console URL. For this example, the Administration Console’s Username and Password are weblogic and weblogic.

6. On the left side navigation panel, click the Deployments link.

7. Click the Install button.

8. Use the Path: field to locate the C:\APEXProxy directory. NOTE: this page can
navigate directories on the drive by entering C:\ and clicking the Next button. The server
returns an error and shows the directories in a navigable list.

Click the radio button next to the apexproxy.war directory name and then click the
Next button. NOTE: do not type in the complete path to the war directory – clicking the
radio button for the WAR automatically completes the Path specification.

9. Click the Next button to accept installing the deployment as an application.

10. Select the desired server and click the Next button.

11. Click the Finish button to accept default values for all the remaining deployment values
and finish the deployment.

12. The Administration Console displays the configuration page for the newly deployed
application with the following messages.

Lower down the page, the server display the status of the new application.

13. Enter the Managed Server URL in to a browser to see the APEX login page.

http://localhost

The browser receives a redirect from the index.html page and displays the APEX login
screen.

Categories: APEX, Oracle Tags: , ,