![]() |
Portal J2EE Sample Chat Application |
Portal J2EE Sample Chat Application
This document describes how to utilize the Portal J2EE sample Chat application in conjunction with Sun ONE Application Server version 7.This sample application document contains the following sections:
Overview
The Chat sample is a simple application that demonstrates a custom Portal Server JSP provider that access the JMS APIs to publish and receive messages to and from a chat room. Starting with the Portal Server 6.1 release, custom portal providers can gain access to J2EE features such as JNDI, EJB, ODBC and JMS that are available only in J2EE containers. This allows Portal Server to provide content generated from any J2EE components and resources that are made available by the underlying J2EE compilant platform.
This document assumes that the Portal Server 6.1 and above release is already deployed on Sun ONE Application Server 7.0 and that you have selected the default installation options with the sample desktop. You must also have superuser(root) privileges for the system where Portal Server is deployed.A snapshot of the sample portal desktop with the chat sample is shown below. Note the channel titled "J2EE Sample - Chat" that shows the current chat room discussions.
![]()
Step by Step Deployment Guide
- Install Portal Server 6.1 or above release on Sun ONE Application Server 7.0. Make sure to install the sample portal since this sample depends on the sample desktop.
- Setup your system to leverage the Sun ONE Application Server 7.0 development environment. This includes setting the PATH environment to include the following directory:
<appserver_basedir>/bin
- Install/Unpack Portal J2EE samples if not already done so. Navigate to the portal server sample deployment root directory for Sun ONE Application Server 7.0 as follows:
cd <portalsample_basedir>/j2eesample/deploy/s1as
- Edit the common.properties file and review the default value for each property. The default property values are set according to the default installation options for Portal Server 6.2 release on Sun ONE Application Server. A description of each property and their default values are listed in the following table:
Property Description Default Value com.sun.aas.javaRoot The JDK directory. For default Sun ONE application server v7.0, this is /usr/j2se. However, Portal Server MAS installation will install JDK 1.4.1_01 and make modifications to the application server's configuration file to use this jdk. /usr/java_1.4.1_01 admin.host This is the hostname where the Sun ONE application server v7.0 admin server is running.
com.sun.aas.imqLib This is the directory where Sun ONE application server v7.0 finds the implementation of JMS provider. /usr/share/lib/imq admin.port This is the port number where the Sun ONE application server v7.0 admin server is listening to 4848 com.sun.aas.installRoot The base directory where Sun ONE application server v7.0 is installed into /opt/SUNWappserver7 admin.user The user id of the administrator account for the Sun ONE application server v7.0 admin server admin sunone.instance The server instance name where portal server is deployed server1 com.sun.aas.webServicesLib The directory where web services library files reside /usr/share/lib com.sun.aas.pointbaseRoot The base directory where pointbase is installed into /opt/SUNWappserver7/pointbase com.sun.dsame.installRoot
The base directory where Identity Server is installed into
/opt/SUNWam
com.sun.portal.installRoot
The base directory where Portal Server is installed into
/opt/SUNWportal
com.sun.portal.deployuri The deployment uri used when deploying portal server on Sun ONE application server v7.0 /portal com.sun.portal.websrcRoot The portal server open WAR file root directory
/opt/SUNWportal/web-src com.sun.portal.provider.classBaseDir The base directory where portal provider class files are deployed /etc/opt/SUNWportal/desktop/classes com.sun.portal.templateBaseDir The base directory where provider templates and JSP are deployed /etc/opt/SUNWportal/desktop com.sun.portal.desktopType The portal server deployed desktop type default sunone.instance.port The port number where the Sun ONE application server instance is listening to 80
- Navigate to the chat sample directory for Sun ONE Application Server 7.0 as follows:
cd <portalsample_basedir>/j2eesample/deploy/s1as/chat
- Compile the custom chat provider by giving the following command:
asant compile
- Deploy the custom portal JSP provider class file and its JSP file to the proper directories using the following command: (note that this requires super user privilege:
asant deployprovider
- Enter the asadmin command mode to create the required jms resources:
cd /opt/SUNWappserver7/bin
./asadmin
- Create a TopicConnectionFactory object with the following asadmin command:
asadmin>create-jms-resource --user admin --password <password> --host localhost --port 4848 --instance server1 --resourcetype javax.jms.TopicConnectionFactory --property imqBrokerHostPort=7676:imqBrokerHostName=localhost:imqConfiguredClientID=bonjour jms/sampleTCF
where <password> is the password for the SunONE application server's administrator account.
- Create a Destination Topic object for the chat room with the following asadmin command:
asadmin>create-jms-resource --user admin --password <password> --host localhost --port 4848 --instance server1 --resourcetype javax.jms.Topic --property imqDestinationName=SampleTopic jms/sampleTopic
where <password> is the password for the Sun ONE application server's administrator account.
- List the jms resources with the following asadmin command:
asadmin>list-jms-resources --user admin --password <password> server1
where <password> is the password for the Sun ONE application server's administrator account. You should see the following object in the result list:
jms/sampleTCP
jms/sampleTopic
- Make the necessary modifications to the portal server web.xml and sun-web.xml files to include references to the Count EJB. These modifications should be made under the portal server open war file source directory. Modifications made in the portal server open war file source directory are guarantee to be effective even when a change such as a patch is applied to the portal server in the future. Locate the portal server open war file source directory and change directory to it. The default portal server open war file source directory is /opt/SUNWportal/web-src. This may change depending on the specific directory where portal server is installed into. (note that this requires super user privilege)
cd /opt/SUNWportal/web-src
- Create a new xml file named ChatSample.xml under the subdirectory of WEB-INF/xml by copying an existing xml file in that directory and removing all the lines between the <web-app> and </web-app> tags in the ChatSample.xml file. Append the following lines to ChatSample.xml between the <web-app> and </web-app> tags and save the file:
<resource-env-ref>
<resource-env-ref-name>jms/sampleTopic</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Topic</resource-env-ref-type>
</resource-env-ref>
<resource-ref>
<res-ref-name>jms/sampleTCF</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
- Edit the sun-web.xml under the subdirectory of WEB-INF to append the following entries at the end of the file.
<resource-env-ref>
<resource-env-ref-name>jms/sampleTopic</resource-env-ref-name>
<jndi-name>jms/sampleTopic</jndi-name>
</resource-env-ref>
<resource-ref>
<res-ref-name>jms/sampleTCF</res-ref-name>
<jndi-name>jms/sampleTCF</jndi-name>
<default-resource-principal>
<name>guest</name>
<password>guest</password>
</default-resource-principal>
</resource-ref>
- Redeploy the portal server by running the following command:
asant redeploy_portal_war
- Login to the Portal Server Admin Console and select the "Service Management" view at the top pane. Click the property icon next to "Desktop Service" in the left pane. Click "Edit XML" and append the content from <portalsample_basedir>/j2eesample/src/com/sun/portal/sample/j2ee/chat/dp-ChatProvider.xml into the textarea and save the change.
- In the Portal Server Admin Console, select the "Identity Management" view at the top pane. Select "Service" in the pulldown in the left pane. Click on the property next to "Desktop Service". Click on "Channel and Container Management" in the content. Under the channel section, create a new channel base on the "ChatProvider" and name it "Chat". Save the channel. Under the container channels section, edit the "MyFrontPageTabPanelContainer" container and move the "Chat" channel to the available and selected channel list of the container. Save the changes.
- Restart the application server.
asadmin stop-appserv
asadmin start-appserv
- Login to portal server as a regular desktop user and bring up the desktop. You should see a channel named "Portal J2EE Sample -Chat" in the front page. The textarea displays the chat messages posted in the public chat room. .
- Make certain that values in the common.properties file are set correctly to reflect your Portal Server installation on Sun ONE Application Server installation.
- You need to have superuser privilege in order to execute certain commands in the step by step guide.
- If you encounter problems when running the application, review the log files at <install-dir>/domains/domain1/<server-instance>/logs/server.log to learn what went wrong.
- The application server admin console should show a Connection Factories named "jms/sampleTCF" and a Destination Resources named "jms/sampletopic" under the JMS tree node in the left pane..
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated March 10, 2003