Java Application Server Guide For Version 10.
Apple Inc. © 2003, 2005 Apple Computer, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Inc.
Contents Introduction Introduction to Java Application Server Guide 7 Organization of This Document 7 See Also 8 Chapter 1 Application Server Overview 9 JBoss in Mac OS X Server 9 Three Deployment Configurations 10 Chapter 2 Configuring Applications 11 Starting the Application Server 11 Configuring Your Application 13 Starting the JBoss Deployment Tool 14 Loading Your Application 14 Configuring Your Application’s Components 17 Saving a Configured Application 18 Deploying Your Application 19 Chapter 3
C O N T E N T S Configure the SupplierPurchaseOrder Module 33 Configure the Supplier Web Application Module 34 Save the Application 35 Deploy and Test the Application 35 Chapter 4 Administering Application Servers 37 Logging In to the Management Tool 37 Choosing a Task 39 Managing Application Servers 40 Configuring Application Servers 43 Monitoring Application Servers 43 Starting and Stopping Services 44 Creating a Data Source 45 Creating a Topic or a Queue 45 Deploying Applications 46 Chapter 5 Balanci
Figures and Tables Chapter 2 Configuring Applications 11 Figure 2-1 Figure 2-2 Figure 2-3 Figure 2-4 Figure 2-5 Figure 2-6 Chapter 3 Configuring and Deploying Sun’s Pet Store 21 Table 3-1 Chapter 4 Relationship information for the Customer module 27 Administering Application Servers 37 Figure 4-1 Figure 4-2 Figure 4-3 Figure 4-4 Figure 4-5 Figure 4-6 Figure 4-7 Chapter 5 The Load Application window of the deployment tool 14 The Loaded Application window 15 The deployment-tool main window 16 The Quic
F I G U R E S A N D T A B L E S 6 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
I N T R O D U C T I O N Introduction to Java Application Server Guide Note: This document was previously titled Mac OS X Server Java Application Server Administration. JBoss is a powerful Java-based open-source application server that is very popular among Java 2, Enterprise Edition (J2EE) application developers. This document describes how to configure and use the JBoss application server in Mac OS X Server, which lets you deploy J2EE applications easily and reliably.
I N T R O D U C T I O N Introduction to Java Application Server Guide See Also To use this document to its fullest, you should download its companion files, which are packaged in Application_Server_companion.zip, located in the same webpage from which you obtained this document. For an introduction to J2EE, visit http://java.sun.com/j2ee. You can get detailed information on JBoss at http://jboss.org. 8 See Also 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R 1 Application Server Overview JBoss is an open-source highly popular Java-based application server. Based on the Java 2, Enterprise Edition (J2EE) platform, JBoss provides an affordable delivery system for enterprise applications. Applications that follow the J2EE standard can be deployed on other application servers, such as WebLogic, WebSphere, and JRun, with little or no modification.
C H A P T E R 1 Application Server Overview In Mac OS X Server, JBoss is configured to use Tomcat (using the AJP connector) as its web server and servlet container. In addition, HTTP and HTTPS (through port 8443) are enabled by default. You can manage the application server from the Server Admin application. This provides you with a simple way to start, stop, and monitor the application server. You can use the command line, if you prefer.
C H A P T E R 2 Configuring Applications Before you can deploy an application on an application server, you have to start the application server and then configure or assemble the application. This is the process through which you specify data sources, database mappings, JNDI resources, and so on. You configure J2EE applications by modifying XML files in META-INF and WEB-INF directories in application archives. Performing this task manually is tedious and error prone.
C H A P T E R 2 Configuring Applications 2. 12 In the Computers & Services list, select Application Server. Starting the Application Server 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R 2 Configuring Applications 3. In the configuration pane, click Settings. From Configuration Name pop-up menu, choose the appropriate configuration. 4. Click the Start Service toolbar button. After a few seconds the application server should be running. You can confirm that JBoss is running by accessing http://localhost:8080 in your web browser. You should see a webpage titled Welcome to JBoss/Tomcat. You can also start JBoss in Terminal with the following command: $ /Library/JBoss/3.
C H A P T E R 2 Configuring Applications Starting the JBoss Deployment Tool To start the deployment tool, double-click DeploymentTool.woa in /Library/JBoss/Applications or enter the following command in Terminal: $ /Library/JBoss/Applications/DeploymentTool.woa/DeploymentTool After a moment, the Load Application window appears. Note: Running the JBoss Deployment Tool requires a web browser that supports Frames and Javascript. Some web browsers may need to have pop-up blocking disabled.
C H A P T E R 2 Configuring Applications After the deployment tool loads the application, it displays the Loaded Application window, shown in “Figure 3-2”. Figure 2-2 2. The Loaded Application window Click “Click here to continue” to move on. The deployment tool displays the main window (also known as the navigation window).
C H A P T E R 2 Configuring Applications Figure 2-3 The deployment-tool main window “Figure 3-3” shows the components of the petstore.ear archive. The following list describes some of the items in the main window: 16 ■ PetStoreEAR (Application) Represents the Pet Store enterprise-application archive. ■ Application Settings Clicking this link allows you to configure settings that affect all the modules in the archive when the application is deployed.
C H A P T E R 2 Configuring Applications Configuring Your Application’s Components To configure a component, you choose it from the main window by clicking the appropriate link. This causes the deployment tool to display the configuration window for the component. As you can see in “Figure 3-4”, this is a tabbed window that contains one or more panes, which you use to configure specific aspects of the component.
C H A P T E R 2 Configuring Applications Figure 2-5 A module-settings window After configuring the elements in a pane, you click Update to confirm the changes. Keep in mind that the changes are not saved until you save the application. Saving a Configured Application To save a configured application, that is, when no components are shown in red in the main window, click Save in the top of the main window. The Save Application window (“Figure 3-6”) appears.
C H A P T E R 2 Configuring Applications Enter the destination of the configured application in the text field of the Save Application window, and click Save Application. Deploying Your Application To deploy a configured application from the deployment tool, simply save the application to /Library/JBoss/3.2/deploy in a single-server deployment or /Library/JBoss/3.2/farm in a cluster deployment. Deploying Your Application 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R 2 Configuring Applications 20 Deploying Your Application 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store Pet Store is a sample J2EE application from Sun Microsystems. Pet Store showcases the power and flexibility of the J2EE platform. This chapter provides a tutorial on the configuration of Sun’s Pet Store for deployment in Mac OS X Server. Sun’s Pet Store is comprised of several applications. This tutorial uses the Pet Store enterprise application and the Supplier enterprise application.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store c. Click Install and then click Start. d. Quit MySQL Manager. 3. Create the Pet Store Tables: a. In Terminal, run the mysql command-line tool. b. Enter use test and press Return. c. Copy the text in Application_Server_companion/Pet_Store_resources/create_tables_sql.txt (in this document’s companion files) to the Clipboard, and paste its contents into the mysql command-line tool. d. Enter quit and press Return. 4.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 5. In the Connect to Server window, enter the host name and the port of the application server. (By default the host is localhost and the port is 1099.) 6. Click Connect to Server. 7. Close the Connect to Server window. Configure Application-Wide Settings In this section you configure the settings that affect all the modules in the petstore.ear archive. 1. Under PetStoreEAR (Application), click Application Settings. 2.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 4. Close the window. Configure the AsyncSender Enterprise Bean 1. Under AsyncSenderEJB (EJB), click Enterprise Beans. Then click AsyncSenderEJB. 2. In the AsyncSenderEJB window, select jms/QueueConnectionFactory in the JBoss Resource Refs list, and click Edit. 3. From the Jndi Name pop-up menu, choose java:/ConnectionFactory , and click Update. 4. In the JBoss Resource Env Refs list, select jms/AsyncSenderQueue , and click Edit. 5.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 6. Click Update to finish configuring the Catalog enterprise bean, and close the window. Configure the Customer Module The following sections guide you through the configuration of the Customer module. Configure Module-Wide Settings This section walks you through setting the data source and data-source mapping for the enterprise beans in the Customer module.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 5. From the Entity Command Name pop-up menu, choose no-select-before-insert. The advantage of configuring the database and the data-source mapping at the module level is that the settings apply to all the enterprise beans in the module. Therefore, you don’t have to configure those settings for each enterprise bean in the module, unless they differ from the ones set for the module. 26 6. Click the CMP - PK Generation tab. 7.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 10. Set Auto Increment to yes. 11. Click the CMP - Relationships tab. 12. Configure the relationships. “Table 4-1” lists the relationship information for the customer module.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store f. Click Update to finish configuring the relationship role. g. Click Update to finish configuring the relationship. 13. Click Update to finish configuring the Customer module settings, and close the window. Configure the Account Enterprise Bean 1. Under CustomerJAR (EJB), click Enterprise Beans. Then click AccountEJB. 2. From the Table Name pop-up menu in the AccountEJB window, choose PS_Account. 3.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store Configure the CreditCard Enterprise Bean 1. Under Enterprise Beans under CustomerJAR (EJB), click CreditCardEJB. 2. From the Table Name pop-up menu in the CreditCardEJB window, choose PS_CreditCard. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 4. In the JBoss Resource Refs list, select url/CatalogDAOSQLURL, and click Edit. 5. In the Resource URL text field, enter http://localhost:8080/petstore/CatalogDAOSQL.xml, and click Update. 6. Click Update to finish configuring the PetStore web application, and close the window. Configure the SignOn Module 1. Under SignOnJAR (EJB), click Module Settings. 2. In the SignOnJAR window, click the CMP - Default Settings tab. 3.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 6. Click Update to finish configuring the Counter enterprise bean, and close the window. Save the Application To save the configured PetStore application, click Save in the navigation window and choose a location for it: 1. Using the Finder or Terminal, create a directory under /Library named Configured_Apps. 2. In the main window, click Save. 3. In the text field in the Save Application window, enter /Library/Configured_Apps/petstore.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store Configure the Supplier Module The following sections explain how to configure the SupplierJAR module. Configure the Module Settings 1. Under SupplierJAR (EJB), click Module Settings. 2. In the SupplierJAR window, click the CMP - Default Settings tab. 3. From the Datasource pop-up menu, choose MySQL 4.0.14 (java:/MySqlDS). 4. From the Datasource Mapping pop-up menu, choose mySql, and click Update. 5. Close the window.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 4. In the JBoss Resource Refs list, select jms/TopicConnectionFactory, and click Edit. 5. From the Jndi Name pop-up menu, choose /ConnectionFactory, and click Update. 6. In the JBoss Resource Env Refs list, select jms/opc/InvoiceTopic, and click Edit. 7. From the Jndi Name pop-up menu, choose /topic/opc/InvoiceTopic, and click Update. 8. Click Update to finish configuring the SupplierOrder message-driven bean, and close the window.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store Configure the ContactInfo Enterprise Bean 1. Under Enterprise Beans under SupplierPurchaseOrderJAR (EJB), click ContactInfoEJB. 2. From the Table Name pop-up menu in the ContactInfoEJB window, choose PS_ContactInfo. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 2. In the JBoss Resource Env Refs list, select jms/opc/InvoiceTopic, and click Edit. 3. From the Jndi Name pop-up menu, choose /topic/opc/InvoiceTopic, and click Update. 4. In the JBoss Resource Refs list, select jms/TopicConnectionFactory, and click Edit. 5. From the Jndi Name pop-up menu, choose /ConnectionFactory, and click Update. 6. Click Update to finish configuring the Supplier web-application module, and close the window.
C H A P T E R 3 Configuring and Deploying Sun’s Pet Store 36 Deploy and Test the Application 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R 4 Administering Application Servers Application-server management involves configuring the services available in an application server, turning services on and off, deploying applications, and monitoring application-server resources. This chapter teaches how to manage application servers, which are JBoss instances running on one or more computers. Logging In to the Management Tool Before you can log in to the management tool, the tool must be running.
C H A P T E R 4 Administering Application Servers There are two types of users with the authority to use the management tool: administrator users (which are members of the appserveradm group) and monitor users (which are members of the appserverusr group). The user defined while configuring Mac OS X Server for the first time is added to the appserveradm group. Note: The management tool allows only registered users to manage, configure, or monitor application servers.
C H A P T E R 4 Administering Application Servers 5. Replace new_value with the appropriate user name. 6. Save the changes and restart your computer. Choosing a Task After logging in to the management tool, the Configuration window appears. This window lets you choose the kind of activity you want to perform with the management tool.
C H A P T E R 4 Administering Application Servers Managing Application Servers To manage an application server, enter the JNDI port of the application server you want to manage (by default, 1099) in the Configuration window (shown in “Figure 5-1”), and click “Manage localhost”. Figure 4-1 The Configuration window of the management tool The left side of the JBoss Management Console window (shown in “Figure 5-2”) lists the application servers available and the resources they provide.
C H A P T E R 4 Administering Application Servers Figure 4-3 The JBoss Management Console window showing the Security Configuration pane of the log-in configuration service When you’re managing the services deployed on the application server, you can also monitor the statistics of deployed applications and resources.
C H A P T E R 4 Administering Application Servers Figure 4-4 The JBoss Management Console window showing the Statistics pane of the Pet Store ShoppingCart enterprise bean When you’re done managing, click JBoss in the server list, and click Logout or Change Configuration. 42 Managing Application Servers 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
C H A P T E R 4 Administering Application Servers Configuring Application Servers To configure local application servers, choose the configuration you want to modify from the “Modify configuration” pop-up menu, and click “Modify configuration” in the Configuration page. The JBoss Management Console window appears. This window allows you to select a service and change its configuration. For example, to configure the transaction-connection factory service, select jms-ds.
C H A P T E R 4 Administering Application Servers Figure 4-6 The JBoss Management Console window showing the statistics of the Deploy Service Starting and Stopping Services You can start and stop services while managing or configuring application servers. To do so, in the application server list, select the application server you want to configure, and click Start/Stop Services in the Host Information pane.
C H A P T E R 4 Administering Application Servers Figure 4-7 The JBoss Management Console window showing the Start or Stop Services pane Creating a Data Source You can create a data source while managing or configuring application servers. To do so, select the application server you want to add the data source to in the server list.
C H A P T E R 4 Administering Application Servers 3. In the Topic or Queue Name text field, enter the name of the topic or queue. 4. Enter the name of the file in which the topic or queue configuration is to be saved in the Filename text field. Deploying Applications You can deploy applications while managing or configuring application servers. Follow these steps to deploy an application: 46 1.
C H A P T E R 5 Balancing User Load and Replicating Sessions HTTP load balancing provides a way to distribute user load among a group of application servers. The application servers can be standalone or configured as a cluster, in which case they are know as nodes. Load balancing is better used with sticky sessions.
C H A P T E R 5 Balancing User Load and Replicating Sessions Figure 5-1 The WebApp window of the petstore.ear archive Load Balancing and Clustering Load balancing provides a way to distribute user load among application servers. Clustering enables session failover when a node in a cluster becomes unavailable. Load balancing can be used with a group of standalone application servers or with a cluster or application server or nodes.
C H A P T E R 5 Balancing User Load and Replicating Sessions 5. Double-click the appropriate site in the list (by default there’s only one), which should be enabled. 6. Click the Options tab, and deselect Performance Cache. 7. Click Save. 8. Open httpd.conf file, located in /etc/httpd, in a text editor. 9. Look for . 10. Add JKMount /petstore/* loadbalancer as the last item of the IfModule element. The IfModule element should look similar to this:
C H A P T E R 5 Balancing User Load and Replicating Sessions The file as configured in Mac OS X Server is shown in “Figure 6-2”. Figure 5-2 The workers.properties file in /etc/httpd 13. Change line 2 to: worker.list=loadbalancer 14. Change line 8 so that it references the first node. It should look similar to this: worker.JBoss1.host=node1.mydomain.com 15. Change line 12 to: worker.JBoss1.cachesize=10 16. Uncomment lines 26 through 28. 17.
C H A P T E R 5 Balancing User Load and Replicating Sessions worker.JBoss2.port=9007 18. Change line 27 so that it references the second node. It should look similar to this: worker.JBoss2.host=node2.mydomain.com 19. Change line 31 to: worker.JBoss2.cachesize=10 20. Add the following line to the file to enable sticky sessions: worker.loadbalancer.sticky_session=1 21. Save the file.
C H A P T E R 5 Balancing User Load and Replicating Sessions Test the Configuration Follow these steps to make sure that client requests are balanced among the application servers: 1. Start the Web service in the web-server computer. 2. Start the application server in each of the application-server computers and run the following commands on both: $ cd /Library/JBoss/Logs $ tail -f localhost_access.log 3.
R E V I S I O N H I S T O R Y Document Revision History This table describes the changes to Java Application Server Guide. Date Notes 2005-08-11 Changed the title from "Mac OS X Server Java Application Server Administration." Made minor edits throughout. 2003-10-22 First version. 53 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
R E V I S I O N H I S T O R Y Document Revision History 54 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.
Glossary application server JBoss instance, which is started through Server Admin. CMP (container-managed persistence) Enterprise bean persistence model in which the J2EE container is responsible for persisting enterprise-bean instances to a data store and populating the fields of enterprise-bean instances when they are retrieved. deployment tool HTML-based application through which J2EE application or component archives can be configured or assembled in preparation for deployment in Mac OS X Server.
G L O S S A R Y 56 2005-08-11 | © 2003, 2005 Apple Computer, Inc. All Rights Reserved.