33 Testing and Deploying Your Portlets

This chapter explains how to test and deploy JSR 168 and Oracle PDK-Java portlets. In a development environment, you can test your portlets on Integrated WebLogic Server (WLS), which comes packaged with Oracle JDeveloper, and also deploy portlet applications to an Oracle WebLogic Managed Server instance residing outside JDeveloper.

This chapter includes the following sections:

For information about testing and deploying other custom WebCenter applications, see Chapter 38, "Testing and Deploying Your WebCenter Application".

For information about creating portlets, see Chapter 30, "Creating Portlets with the Oracle JSF Portlet Bridge" and Chapter 31, "Creating Portlets with the Portlet Wizard".

33.1 Introduction to Portlet Deployment Testing in a Development Environment

Before you deploy your portlet application, you are advised to test it in a development environment. Integrated WLS in JDeveloper enables you to test your portlets in a single step, without creating a deployment profile. To learn the benefits of testing applications on Integrated WLS, see Integrated WebLogic Server. An additional benefit is that portlet customizations that you perform at design time are maintained in your application workspace and become an integral part of the application source definition. These changes are packaged with the EAR file when the application is deployed to a WebLogic Managed Server instance (managed servers). This eliminates the requirement to export and import portlet customizations.

To test your portlet application on an Oracle WebLogic Managed Server instance, or to deploy for production, you must configure a connection to the managed server, create deployment plans, and then deploy to the server instance as described in this chapter. For information about deploying portlet applications using Oracle Enterprise Manager Fusion Middleware Control, WLS Administration Control, or WLST commands, see the chapter, "Managing Portlet Producers" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter.

33.2 Testing a Portlet Application on Integrated WebLogic Server

The connection to Integrated WLS (Default Server) connection is preconfigured and shows as IntegratedWLSConnection under the Application Server node in the IDE Connections panel of the Resource Palette, as shown in Figure 33-1. You can run multiple applications simultaneously and watch the progress of each application in the Run Manager panel. The Run Manager panel also lets you stop Default Server instances.

Figure 33-1 IntegratedWLSConnection in IDE Connections

Description of Figure 33-1 follows
Description of "Figure 33-1 IntegratedWLSConnection in IDE Connections"

For more information about Integrated WLS Server, see Integrated WebLogic Server.

This section includes the following subsections:

33.2.1 How to Test JSR 168 Portlets on Integrated WebLogic Server

When you run your portlet application on Integrated WLS, an instance of Default Server starts.

To test a JSR 168 portlet application:

  1. Right-click the portlet.xml page in the project folder and select Run. Running portlet.xml triggers packaging and deployment of your portlet application on an instance of Integrated WLS named after the application.

    Note:

    When the Integrated WLS instance stops, the application is undeployed, and therefore, becomes unavailable.

    For a more persistent testing scenario, you can deploy your portlet application to Integrated WLS by right-clicking the application and then selecting Deploy. This deploys your application to the Default Server instance so that it is always available when the Default Server is running. Thus, the application remains accessible for multiple consumer applications. If you choose this method, then you must first create deployment profiles, as described in Section 33.3.1, "How to Create Deployment Profiles". If you deploy your application to Integrated WLS, then the Deployment Configuration dialog displays to let you configure and customize deployment settings. The file system MDS repository pre-created by JDeveloper displays in the Repository Name field.

  2. In the Select deployment type dialog, select Yes and then click OK.

    See the DefaultServer Log window to monitor the deployment progress. The DefaultServer - Log shows the URL of the application page. The WSRP producer URL uses the following syntax:

    http://host:port/applicationname-Portlets-context-root/info
    

    where:

    • host is the server to which your producer has been deployed.

    • port is the HTTP Listener port. Typically, it is 7101. When the server is started, the port is displayed in the console.

    • context-root is the Web application's context root.

    A test page similar to Figure 33-2 displays in a browser window.

    Figure 33-2 WSRP Producer Test Page

    Description of Figure 33-2 follows
    Description of "Figure 33-2 WSRP Producer Test Page"

    Note:

    This procedure is for testing purposes only. After this procedure, you are required to register your producer as described in Section 33.4, "Registering and Viewing Your Portlet".

33.2.2 What Happens When You Test JSR 168 Portlets on Integrated WebLogic Server

When you run JSR 168 portlets on Integrated WLS, the following happens:

  • wsdls and other configuration files are added to the WEB-INF directory to configure the portlets as a Web service.

  • The web.xml file is updated with listener and server classes, filters, parameters, and other configurations that are required to run the JSR 168 portlet application successfully.

    For example, the oracle.portlet.server.adapter.web.ServerContextListener class, WSRP_v2_PortletManagement_Service and WSRPBaseService filters, and so on.

  • Libraries required for JSR 168 portlets are added to the weblogic.xml file, for example, oracle.portlet-producer.wsrp.

These configurations vary depending upon the portlet requirements.

33.2.3 How to Test PDK-Java Portlet Applications on Integrated WebLogic Server

When you run your portlet application on Integrated WLS, an instance of Default Server starts.

To test a portlet application, right-click a JSP page, for example, index.jsp in the project folder and select Run. Running index.jsp triggers packaging and deployment of your portlet application on an instance of Integrated WLS named after the application.

Note:

When the Integrated WLS instance stops, the application is undeployed, and therefore, becomes unavailable.

For a more persistent testing scenario, you can deploy your portlet application to Integrated WLS by right-clicking the application and then selecting Deploy. This deploys your application to the Default Server instance so that it is always available when the default server is running. Thus, the application remains accessible for multiple consumer applications. If you choose this method, then you must first create deployment profiles, as described in Section 33.3.1, "How to Create Deployment Profiles". If you deploy your application to Integrated WLS, then the Deployment Configuration dialog displays to let you configure and customize deployment settings. The file system MDS repository pre-created by JDeveloper displays in the Repository Name field.

See the DefaultServer Log window to monitor the deployment progress. The DefaultServer - Log shows the URL of the application test page, as shown in Figure 33-3. The format of the URL is http://host:port/application_name-Portlets-context-root/index.jsp.

Figure 33-3 DefaultServer - Log

Description of Figure 33-3 follows
Description of "Figure 33-3 DefaultServer - Log"

The PDK-Java Application Test page displays in a browser window, as shown in Figure 33-4.

Figure 33-4 Portlet Application Test Page

Description of Figure 33-4 follows
Description of "Figure 33-4 Portlet Application Test Page"

Click the link underneath Service Name. Your browser should open with a page similar to the one shown in Figure 33-5. The URL of this page is the one required to register the producer with another application.

Figure 33-5 Producer Test Page

Shows provider test page.
Description of "Figure 33-5 Producer Test Page"

Alternatively, you can construct the URL yourself as follows:

http://host:port/context-root/providers/producer_name

where:

host is the server to which your producer has been deployed.

port is the HTTP Listener port. Typically, it is 7101. When the server is started, the port is displayed in the console.

context-root is the Web Application's Context Root, which you specified earlier and can be found in the WAR Deployment Profile Properties under General.

producer_name is the name of the portlet's producer. A WAR file may contain multiple producers, hence you should always include the name of the producer for clarity. Otherwise, you get the default producer, which is the first producer created. The default producer is defined by the _default.properties file. This is created with the first producer in a project.

If you enter this URL in your browser, you should see a page similar to the one in Figure 33-5.

33.2.4 What Happens When You Test PDK-Java Portlet Applications on Integrated WebLogic Server

When you run PDK-Java portlets on Integrated WLS the following happens:

  • Configuration files for PDK-Java portlets are added to the WEB-INF directory.

  • The web.xml file is updated with listener and server classes, filters, parameters, and other configurations that are required to run the portlet application successfully.

    For example, the ResourceServlet pdkresource, the oracle.portlet.server.service.ContextFilter filter, and so on. These configurations vary depending upon the portlet requirements.

  • Libraries required for PDK-Java portlets are added to the weblogic.xml file, for example, oracle.portlet-producer.jpdk.

33.3 Deploying a Portlet Application to an Oracle WebLogic Managed Server Instance

To test your portlet application on an Oracle WebLogic Managed Server instance, or to deploy it for production, you must first create an application WAR deployment profile, a deployment descriptor, and a connection to the Oracle WebLogic Managed Server instance. Before you deploy or test your portlet application to a managed server, ensure that the managed server is created using the correct template and it contains all the required shared libraries as described in the section "Creating and Provisioning a WebLogic Managed Server Instance" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter.

For information about deploying portlet applications using Oracle Enterprise Manager Fusion Middleware Control, Oracle WebLogic Administration Console, or WLST commands, see the chapter, "Managing Portlet Producers" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter.

This section includes the following subsections:

33.3.1 How to Create Deployment Profiles

The project-level deployment profile is packaged as a Web Application Archive (WAR) file. Deployment descriptors are server configuration files that define the configuration of an application for deployment and are deployed with the portlet application as needed. The deployment descriptors that a project requires depend on the technologies the project uses and on the type of the target application server.

Note:

You can deploy PDK-Java portlets only as EAR files. Therefore, while creating deployment profiles, ensure that the WAR file is included in the application's EAR file. For information about how to create an EAR file, see Section 38.3.1.2, "Creating Deployment Profiles" in Chapter 38, "Testing and Deploying Your WebCenter Application".

This section includes the following subsections:

33.3.1.1 Creating a WAR Deployment Profile

To create a WAR deployment profile:

  1. In the Application Navigator, expand Web Content and WEB-INF.

  2. Right-click web.xml and choose Create WAR Deployment Profile.

    Alternatively, from the main menu, choose File and then New. In the New Gallery, expand General, select Deployment Profiles and then WAR File, and click OK.

  3. In the Create Deployment Profile -- WAR File dialog, enter a name for your deployment profile and click OK.

  4. In the Edit WAR Deployment Profile Properties dialog, select the Specify Java EE Web Context Root option and enter a context root. You can also enter the name of the deployment profile. Then click OK.

  5. In the Project Properties dialog, under Deployment Profiles, select the WAR File you just created and click OK.

33.3.1.2 Creating a Deployment Descriptor

To create a deployment descriptor:

  1. From the main menu, choose File and then New.

  2. In the New Gallery, expand General, select Deployment Descriptors and then Java EE Deployment Descriptor, and click OK.

  3. In the Create Java EE Deployment Descriptor dialog, on steps 1 to 4, accept the default values and click Finish.

33.3.2 How to Create and Provision a WebLogic Managed Server Instance

To deploy a portlet producer application to a WebLogic Managed Server instance, you must first create a server instance and provision it with a required set of shared libraries. For more information, see the section "Creating and Provisioning a WebLogic Managed Server Instance" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter.

33.3.3 How to Create and Register the Metadata Service Repository

After creating the WebLogic Managed Server instance, you must create and register a Metadata Service Repository (MDS) schema for the application on the WebLogic Domain's Administration Server instance. For more information, see the section "Creating and Registering the Metadata Service (MDS) Repository" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter.

33.3.4 How to Create a WebLogic Managed Server Connection

In JDeveloper, you can deploy your portlet applications to Oracle WebLogic Managed Server instances that reside outside JDeveloper. You must first create a connection to the server instance.

Before You Begin:

Before you create a connection to the managed server, ensure that the server instance is up and running.

To create a WebLogic Managed Server connection:

  1. From the main menu, select File and then New.

  2. In the New Gallery, expand General, select Connections and then Application Server Connection, and click OK.

  3. In the Create Application Server Connection wizard, on Step 1, enter a name for the new connection, for example, PortletServer. Then click Next.

  4. On Step 2, specify the user name and password for authentication and click Next.

  5. On Step 3, enter the host name of the WebLogic Server instance, for example, webcenter.portletserver.oracle.com and the port number, for example, 7001.

  6. In the WLS Domain, specify the name of the domain in which the WebLogic Server instance is created, for example, wc_domain. Click Next.

  7. On Step 4, click Test Connection. If the test is successful, the connection is set up.

  8. Click Finish.

33.3.5 How to Deploy a Portlet Application to an Oracle WebLogic Managed Server Instance

After you have created the deployment profiles and a connection to the managed server for portlet deployment, you can deploy your portlet application to this server instance.

To deploy a portlet application:

  1. In the Application Navigator, open the application to be deployed.

  2. Right-click the project folder, choose Deploy, deployment profile name, to, and then choose the connection name.

    Note:

    If your portlet application contains JSR 168 portlets, then the Select deployment type dialog displays. Click OK to add the configuration required to expose this application as a WSRP service.
  3. In the Select Deployment Target dialog, select the managed server name, for example, WLS_Portlet, and click OK.

  4. In the Deployment Configuration dialog, under the MDS tab, in the Repository Name dropdown list, select the metadata repository to be used by the application you are deploying.

  5. In the Partition Name field, specify the application's partition name. Each application is recommended to have its own partition. The application name can be used as the partition name.

  6. Under the Connections tab, modify the connections packaged with the portlet producer application being deployed.

    Note:

    Consider the following about producer connections:
    • In the Connections tab, you cannot change secure properties of the connections. You can modify these connections post-deployment using Fusion Middleware Control. For information, see the chapter "Managing Services" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter.

    • To edit a WSRP connection, you must also edit the associated Web service connection, which follows the naming convention connectionname-wsconn, for example, myWSRPproducer-wsconn.

    • To edit PDK-Java producers, you must also edit the underlying URL connection, which follows the naming convention connectionname-urlconn, for example, myPDKproducer-urlconn.

    • WSRP 1.0 standard does not support export and import capabilities. Therefore, customizations made to WSRP 1.0 producers are not migrated during deployment.

  7. Click Deploy. The Deployment - Log displays the deployment status.

    The message Deployment started displays in the Deployment - Log window. If the application is successfully deployed to the targeted server instance, the message Deployment finished displays in the log.

33.3.6 What Happens When You Deploy a Portlet Application to an Oracle WebLogic-Managed Portlet Server

If you are deploying JSR 168 portlets, the configuration settings described in Section 33.2.2, "What Happens When You Test JSR 168 Portlets on Integrated WebLogic Server" are added to the EAR file.

If you are deploying PDK-Java portlets, the configuration settings described in Section 33.2.4, "What Happens When You Test PDK-Java Portlet Applications on Integrated WebLogic Server" are added to the application EAR file at design time.

33.4 Registering and Viewing Your Portlet

After you have created and deployed the producer and its portlets, you should register the producer with an application and add one or more portlets to a page to check that it is working correctly. Registering a producer gives applications the information they require to locate and communicate with that producer. After you register a producer, it is exposed as a connection, and the producer and its portlets become available in the Application Resources panel under the Connections node, or in the Resource Palette.

To register producers for your JSR 168 portlets, follow the instructions provided in Section 34.2.1, "How to Register a WSRP Portlet Producer".

To register producers for your PDK-Java portlets, follow the instructions provided in Section 34.2.3, "How to Register an Oracle PDK-Java Portlet Producer".

To add your portlets to a page, follow the instructions provided in Section 34.3, "Adding Portlets to a Page".