Deploying A Portlet To Sun Java Portal Server: April 2006 (Revision Number: V2.1-1)
Deploying A Portlet To Sun Java Portal Server: April 2006 (Revision Number: V2.1-1)
Deploying A Portlet To Sun Java Portal Server: April 2006 (Revision Number: V2.1-1)
This tutorial describes the process of deploying a JSR-168-compliant JavaServer Faces portlet application that you developed using Sun Java Studio Creator's Integrated Development Environment (IDE) to a stand-alone Sun Java System Portal Server. You create a web application archive (WAR) file for your portlet using the IDE, configure settings in the portal server, and then deploy the WAR file on the Sun Java System Portal Server. To complete this tutorial, you must have access to a stand-alone Sun Java System Portal Server and you should be familiar with portal server technology. If you are unfamiliar with the Sun Java System Portal Server, download it, install it, and read its documentation before proceeding with this tutorial. Make sure that you download and install the latest available version of the Sun Java System Portal Server. You need to use at least version 6. Online help is available from the portal server menu. This tutorial is based upon Sun Portal Server versions 6 and 7 for the Solaris operating system. Before you deploy your portlet to a stand-alone Sun Java System Portal Server, you must first ensure that the portlet deploys successfully to the Apache Pluto Portlet container that is bundled with the IDE. If your application uses JDBC data sources, you must integrate the corresponding database drivers into the portal server before you deploy your portlet. Contents - About Portlet Deployment - Exporting the Portlet WAR File - Configuring EJB Components in the sun-web.xml File - Adding the sun-web.xml File Into the Exported WAR File - Configuring a Sample Data Source - Deploying the Portlet on Sun Portal Server 6 - Deploying the Portlet on Sun Portal Server 7
Figure 1: Export WAR Dialog Box 2. Choose the J2EE platform that matches the platform of the target web container on which your production portal server is running. If you are not sure, check with your portal administrator for the correct platform. 3. Select a file name for the exported WAR file and then click OK. The IDE builds the portlet WAR file and displays a BUILD SUCCESSFUL message when the build process completes. If the process is not successful, the IDE displays an appropriate error message.
Code Sample 1: Sample sun-web.xml File <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc. //DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd "> <sun-web-app error-url=""> <!--# ++ properties ++ #Fri Jan 27 10:04:06 MST 2006 project.is_portlet=true project.portlet_name=AllServices project.web_context=/AllServices --> <context-root>/AllServices</context-root> <ejb-ref> <ejb-ref-name>GreeterEJB</ejb-ref-name> <jndi-name>corbaname:iiop:localhost:23700#GreeterEJB</jndi-name> </ejb-ref> <resource-ref> <res-ref-name>jdbc/Travel</res-ref-name> <jndi-name>jdbc/Travel</jndi-name> </resource-ref> <class-loader delegate="false"/> <jsp-config> <property name="classdebuginfo" value="true"> <description>Enable debug info compilation in the generated servlet class</description> </property> <property name="mappedfile" value="true"> <description>Maintain a one-to-one correspondence between static content and the generated servlet class' java code</description> </property> </jsp-config> </sun-web-app>
Note that the EJB component reference <jndi-name>corbaname:iiop:localhost:23700#GreeterEJB</jndi-name> refers to localhost. To correctly configure the EJB component reference, replace localhost with the name of your Sun Java Portal Server host machine.
3. Copy the sun-web.xml file that you created in the previous section to the portlet project's WEB-INF directory. For example: cp ../../web/WEB-INF/sun-web.xml ./WEB-INF 4. In the portlet application's project directory, remove the original exported WAR file. 5. Recreate the WAR file. For example: jar cvf ../JDBCPortlet.war *
The process of recreating the WAR file adds the modified sun-web.xml file to the exported WAR file. 6. Copy the modified WAR file to the target system on which your Sun Java Portal Server is installed. The exported WAR file's default location is in the portlet project directory's dist directory. For example, Creator/Projects/ portletname/dist/portletname.war.
Figure 3: Connection Pools 3. Click New. The Create Connection Pool wizard opens in your web browser. 4. Enter the following values in the General Settings section: Property Value Name TravelDBPool Resource Type Choose javax.sql.DataSource from the drop-down menu. Database Vendor Leave this text field blank. 5. Click Next. The page refreshes, showing the information you just entered as well as the default Datasource Classname. 6. Enter a name in the Datasource Classname field (for example, com.sun.sql.datasource.DriverAdapter) and click Next. More Connection Pool wizard sections display, including the Pool Settings, Connection Validation, Transaction Isolation, and Properties sections. You accept the default values for most of these sections. 7. Enter the following values in the Properties section: Property url Value jdbc:derby//hostname:21527/sample
Username travel Password travel driverClassName org.apache.derby.jdbc.ClientDriver User travel 8. Click Finish. The Connection Pool window opens in the admin console. The Current Pools list includes TravelDBPool. 9. Create a JDBC resource that points to the TravelDB connection pool. From the Common Tasks window, expand the Resources > JDBC nodes, then click JDBC Resources. The JDBC Resources window opens in your web browser, displaying a list of current resources, similar to the following figure.
Figure 4: JDBC Resources Window 10. Click New. The JDBC Resource wizard opens, as shown in the following figure.
Figure 5: JDBC Resources Wizard 11. Enter the following values: Resource Value JNDI Name jdbc/Travel Pool Name Choose TravelDBPool from the drop-down menu. Enable Status Targets Click the Add button to move server from the Available pane to the Selected pane.
The JDCB Resources window opens in your web browser. The jdbc/Travel resource appears in the Current Resources list. 13. Copy the driveradapter.jar library from the Sun Java Studio Creator installation directory to the Sun Application Server lib directory. For example, on the Solaris operating system, copy ${CREATOR_HOME}/SunAppServer8/lib/driveradaptor.jar to /opt/ SUNWappserver/appserver/lib on the Sun Application Server host. 14. Copy ${CREATOR_HOME}/SunAppServer8/lib/derbyclient.jar and derbynet.jar to /opt/SUNWappserver/ appserver/lib on the Sun Application Server host. 15. Restart the Application Server.
For more information about configuring JDBC Resources in the Sun Application Server, see Chapter 3 in the Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Administration Guide.
Note: For a complete description of pdeploy, see Chapter 11 in the Sun Java System Portal Server 6 2005Q1 Technical Reference Guide. The following example illustrates the pdeploy command for an exported WAR file named Portlet1.war. Code Sample 3: pdeploy Command /opt/SUNWps/bin/pdeploy deploy \ -u "uid=amAdmin,ou=People,dc=sesta,dc=com" \ -w admin \ -p sunjava \ -d "dc=sesta,dc=com" \ /tmp/Portlet1.war
2. After successfully executing, pdeploy displays the following message: Done Updating Display Profile! Deploying War File to Web Container... SUCCESS. 3. To deploy the same portlet application a second time, you must first undeploy the portlet as follows: pdeploy undeploy -u uid -w password {-g|-d dn} -p webcontainerpassword portlet-name where webcontainerpassword specifies the password of the portlet application's web container, and portlet-name specifies the name of the portlet application to undeploy.
Note: For a complete description of pdeploy undeploy, see Chapter 11 in the Sun Java System Portal Server 6 2005Q1 Technical Reference Guide.
Registering a Channel For the Portlet Now you use the Sun Java System Access Manager Administration Console to update the Portal Server display profile and register a channel for the portlet. The default location for the Administration Console is http://host:port/amconsole.
1. Log in as administrator to the Sun Java System Access Manager Administration Console. The default administrator login is amadmin. After you log in, the console by default selects Identity Management in the location pane, and the navigation pane displays all created organizations. 2. Select the organization, suborganization, or role to which you want to add a channel. When you log in as a delegated administrator, the console automatically takes you to the organization, suborganization, or role to which you have administrative access. 3. Choose Services from the View menu in the navigation pane. 4. Open the Portal Desktop attributes (or properties) page. Click the properties arrow next to Portal Desktop in the navigation pane. This opens the Desktop attributes page in the data pane. 5. Click the Manage Channels and Containers link in the Desktop page. The Channels page displays with the container path set to the root level. 6. Click New Portlet Channel to open the New Channel page and add the portlet channel to the root of the display profile. 7. In the New Channel page, enter a channel name (following the rules outlined in the page) and select the portlet identifier. The Portlet identifier menu lists the exported portlet from the IDE. 8. Click OK to create the channel. The Channels page appears. You can see the portlet channel you just created by scrolling to the list of channels.
Adding the Channel To a Container You next add the channel you just created to a container so that the channel displays on the portal desktop. You add the channel to a container using the Sun Java System Access Manager Administration Console.
1. From the list of Container Channels at the top of the Channels page, click the name of the container to which you want to add the new portlet channel. For example, for the default sample portal, MyFrontPageTabPanelContainer is the container for the front page tab on that portal. 2. Scroll to Channel Management and select the channel you just created and registered. 3. Click the Add button for the option to move the channel to Available to End Users on the Content Page. 4. While the channel is still selected, click the Add button for the option to move the channel to Visible on the Portal Desktop. 5. Click Save. Note: Once you update the Sun Java Portal Server 6 display profile for your portlet application, you do not have to do further updates if you are undeploying and redeploying the same portlet application, assuming that you keep the same portlet and channel names. To learn more about administering the display profile, see Chapter 10 in the Sun Java System Portal Server 6 2005Q1 Administration Guide.
Figure 6: Deploy Portlet Wizard 3. Enter the following values: Deployment Setting Value Select Portal portal1 Select Location DeveloperSample 4. Click Next. 5. Choose File. The Choose a War File window opens, displaying files on the target file system on which you are running the Sun Portal Server 7 admin console. Choose the portlet WAR file that you copied earlier to the target system. 6. Click Finish.
Selecting the Portlet's Portal and Location 1. Choose Manage Channels & Containers. The Manage Channels & Containers wizard opens. 2. Enter the following values: Setting Value Select Portal: portal-name, where portal-name is the name of your target portal Select Location DeveloperSample 3. Click OK.
Creating a New Channel for the Portlet 1. Select the tab container MyFrontPageTabPanelContainer under JSPTabContainer. 2. Select New Channel/Container under Container Tasks. The New Channel wizard opens, similar to the following figure.
Figure 7: New Channel Wizard 3. Enter the following values: Setting Select Portal Select Location Type 4. Click Next. 5. For Channel Type, enter JSR 168 Portlet Channel, then click Next. A list of portlets appears. 6. Choose your deployed portlet, then click Next. 7. Choose a Channel Name, then click Next. 8. Click Finish. The portlet application deploys to the production Sun Portal Server 7. You can now log in to the Sun Portal Server desktop to test the portlet channel. The test user account login is developer, password developer. To learn more about Sun Portal Server 7, see Sun Java System Portal Server 7 documentation. See Also:
q q q q q
Creating a Portlet Application Sun Java Enterprise System documentation Sun Developer Network Forum - Portal Server David Botterill's Weblog Greg Ziebold's Weblog
More Developer Resources: For more tutorials, articles, tips, forums, updates, and expert advice for developers, visit the Java Studio Creator developer resources on the Sun Developer Network (SDN) at http://developers.sun.com/jscreator/.
q q q q q q q q q
Sun Java Studio Creator integrated development environment (IDE) Sun Java System Application Server version number (Application Server) Java Platform, Standard Edition technology (Java SE(tm) platform) JavaServer(tm) Faces technology JavaServer Pages(tm) technology (JSP(tm) technology) Sun Java System Web Server version number (Web Server) Java Database Connectivity software (JDBC software) Enterprise JavaBeans(tm) specification (EJB(tm) specification) Solaris(tm) Operating System software (Solaris OS software)
The following third-party trademarked terms might be used in the Sun Java Studio Creator tutorials:
q q
Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries. U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and the Java Coffee Cup logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.This product is covered and controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited. Note: Sun is not responsible for the availability of third-party web sites mentioned in this document and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods, or services available on or through any such sites or resources.
Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, tats-Unis. Tous droits rservs. Sun Microsystems, Inc. dtient les droits de proprit intellectuels relatifs la technologie incorpore dans le produit qui est dcrit dans ce document. En particulier, et ce sans limitation, ces droits de proprit intellectuelle peuvent inclure un ou plus des brevets amricains lists l'adresse http://www.sun. com/patents et un ou les brevets supplmentaires ou les applications de brevet en attente aux tats-Unis et dans les autres pays. L'utilisation est soumise aux termes de la Licence. Sun, Sun Microsystems, le logo Sun, Java et le logo Java Coffee Cup sont des marques de fabrique ou des marques dposes de Sun Microsystems, Inc. aux tats-Unis et dans d'autres pays.Ce produit est soumis la lgislation amricaine en matire de contrle des exportations et peut tre soumis la rglementation en vigueur dans d'autres pays dans le domaine des exportations et importations. Les utilisations, ou utilisateurs finaux, pour des armes nuclaires,des missiles, des armes biologiques et chimiques ou du nuclaire maritime, directement ou indirectement, sont strictement interdites. Les exportations ou rexportations vers les pays sous embargo amricain, ou vers des entits figurant sur les listes d'exclusion d'exportation amricaines, y compris, mais de manire non exhaustive, la liste de personnes qui font objet d'un ordre de ne pas participer, d'une faon directe ou indirecte, aux exportations des produits ou des services qui sont rgis par la lgislation amricaine en matire de contrle des exportations et la liste de ressortissants spcifiquement dsigns, sont rigoureusement interdites. Sun Microsystems n'est pas responsable de la disponibilit de tiers emplacements d'enchanement mentionns dans ce document et n'approuve pas et n'est pas responsable ou iresponsable d'aucun contenu, de la publicit, de produits, ou d'autres matriaux dessus ou fournis par de tels emplacements ou ressources. Sun ne sera pas responsable ou iresponsable d'aucuns dommages ou perte causs ou allgus pour tre caus par ou en liaison avec l'utilisation de ce produit ou la confiance dans des tels contenu, marchandises, ou services disponibles sur ou par des tels emplacements ou ressources.
10