Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
HP-UX Java™ – How To Develop Java Applications for HP-UX HP Part Number: 5900-1302 Published: January 2011 Edition: 1.0 © Copyright 2007, 2011 Hewlett-Packard Development Company, L.P. Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. The information contained herein is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein. UNIX is a registered trademark of The Open Group. Table of Contents 1 Introduction................................................................................................................................4 Structure of typical applications...........................................................................................4 Choices for development platform.......................................................................................5 Prepare HP-UX for Java™ deployment...............................................................................7 Debugging a Java™ application ..........................................................................................7 Developing a web service ....................................................................................................8 Tuning a Java™ application for optimum performance......................................................8 Testing for Performance and Reliability...............................................................................9 Special considerations for cross-platform development .....................................................9 Source code control.............................................................................................................10 Monitoring an enterprise application ................................................................................10 2 Development Tools to Deploy Applications on HP-UX....................................................................11 Development Lifecycle.......................................................................................................11 Development Tools.............................................................................................................11 Borland Together ControlCenter...................................................................................11 IBM Rational Rose Developer.......................................................................................11 Simplicity for Java™ .....................................................................................................11 eXoDy application generation framework....................................................................12 Emacs editor..................................................................................................................12 jdb Debugger.................................................................................................................13 Jtest by ParaSoft® .........................................................................................................13 HPjmeter........................................................................................................................13 HP TransactionVision....................................................................................................14 Table of Contents 3 1 Introduction This paper describes the mechanics of developing or porting an application to run on or be hosted by an HP-UX server. The information is applicable to both HP9000 PA-RISC and HP Integrity (Itanium) platforms. The paper presents several alternatives for the development platform and recommends a number of development tools for each of the alternatives. The Development lifecycle is discussed, including the steps of code creation, source code control, debugging, and performance tuning. In addition, this paper provides directions for setting up the HP-UX environment for optimal running of Java™ applications. The HP-UX server platform is ideally suited for deploying Java-based applications. The Apache Web Server and the HP-UX Java™ Virtual Machine provide a low-cost, high-performance foundation for the most sophisticated enterprise applications. A comprehensive set of development tools is available to develop applications on this platform or to port applications from other platforms. These tools also provide the means for tuning the application and the environment to realize the outstanding performance and scalability that is inherent in HP-UX itself. Structure of typical applications A typical application is built using an n-tier model. Not all applications contain all of the tiers, but this is a good general model for the purpose of this paper. The advantages of the n-tier structure are: • The infrastructure is already provided by means of industry-standard components: web browsers, web servers, and application servers. They have already been developed and tested by the platform vendor or by various partners and do not need to be developed from scratch. • These infrastructure components are capable of load balancing and automatic fail-over, thus providing both scalability and reliability. • The portions of the application that run on these standard components are easily ported to other platforms, particularly those that support the same application server. The various types of web and Java™ software to be developed are briefly described below. Each of these software components can be developed for HP-UX deployment by using the tools described later in this paper. HTML - HyperText Markup Language - This is a document-formatting language that is used to create web pages. It has the capability of doing simple formatting using basic text or it can also contain embedded graphics and/or Java™ programs to be executed on the client. Applet - A Java™ program that runs in the context of a web browser. Applets are commonly passed to a client computer within an html stream and run on the client using a Java™ Virtual Machine that is referenced by the client browser. An applet is 4 Introduction used to interact programmatically with the end user in a manner that is not available in the simple html language. Servlet - A Java™ program that runs on a server machine within the context of a web server. JSP - Java™ Server Pages - This is Java™ code embedded in html and executed as a servlet. J2EE - Java™ 2 Enterprise Edition. This is a Java™ specification that defines the functionality and interfaces for Java™ Server Pages and Enterprise Java™ Beans. All Java™ application servers are compatible with some or all of the J2EE specification. EJB - Enterprise Java™ Beans - This is a definition for structuring and encapsulating portions of a Java™ program for execution within a Java™ application server. C/C++ - Programming languages that compile directly to native code. These programming languages have been used historically because of the performance benefits of compiled code as compared to interpreted code and large numbers of existing applications are written in these languages. Web browser - A program that creates a Graphical User Interface for end-user interaction. Examples are Internet Explorer, or Mozilla. Web server - A program that serves pages to multiple web browsers and provides the environment to execute servlets on their behalf. The web server is able to provide load balancing and fail-over across multiple machines in order to service a large number of client browsers. The Apache Web Server and Microsoft IIS are examples of web servers. Application server - A program that provides the environment for executing the business logic of an n-tier application. The typical application server is compatible with some or all of the J2EE specification. The application server is able to provide load balancing and fail-over across multiple machines in order to service a large number of requests. It also provides a transaction encapsulation mechanism for managing accesses to databases and files, as well as a simplified interface from Java™ to relational databases. An example is BEA's web logic server. Choices for development platform The fundamental Choices for development platform can be summarized as the following: • Develop directly on an HP-UX server using simple editors such as EMACS or vi. In this environment, the source code is entered and edited directly on the server. • Develop directly on an HP-UX server using an Integrated Development Environment (IDE) tool that runs directly on the server platform and remotely displays the GUI. In this environment, the source code is entered and edited directly on the server. • Develop on a desktop workstation that runs the development tools and remotely targets the HP-UX server for real-time debugging and monitoring. In this environment, the source code is entered and edited on the workstation but the Choices for development platform 5 • application runs in its target environment on the HP-UX server. Typical desktop workstation operating systems include Windows, Linux, and Unix. Develop on another platform and port to HP-UX. In this environment, the development platform can be any machine that supports a compatible version of the Java™ Runtime Environment, i.e., the Java™ Virtual Machine and associated class libraries. If this option is chosen, the portions of this paper that will be of special interest are those that deal with setting the HP-UX kernel parameters for optimum server performance. Developers have strong individual preferences for the choice of development platform and development tools. Therefore, HP has established partnerships with a wide variety of leading tool vendors in order to provide choices. Furthermore, no particular choice is given preference over the others: all are supported equally by HP. The fundamental differences have to do with where the development tool runs. If the decision is to use EMACS or vi, then the recommended option will be to run the editor directly on the server. If on the other hand an IDE will be used, then the recommended option will be to run the tool on a desktop workstation with remote targeting of the HP-UX server. In the case of native development on HP-UX, the tool runs directly on the HP-UX server and the editing of source code and the debugging information is displayed remotely on an attached graphics terminal. The terminal can be a directly-connected graphics terminal, an X-term, or an X-term emulator running on a Windows desktop. Recommended tools for native development include EMACS, vi, and Simplicity by Data Representations. When installing EMACS, it is recommended that you use an HP-UX configuration file that is available for download from the EMACS page referenced in this paragraph. Note that EMACS only provide code editing and color-coding. Simplicity, on the other hand, is an inexpensive, full-featured Integrated Development Environment that includes a debugger as well as support for the design of web pages, applets, servlets, EJBs, etc. The best development performance with Simplicity will be achieved if used with a directly-connect graphics terminal. This is because Simplicity, like most IDEs, is written in Java™ and runs on a Java™ Virtual Machine. There is a known graphics performance problem in the Java™ Software Development Kit in releases 1.3 and below that causes slow performance when any Java-based GUI is displayed by means of an X-term. This performance problem is also the reason for the blanket statement (above) that IDEs are recommended for use only on desktop workstations with remote targeting of the server. (The remote graphics performance problem is repaired in SDK 1.4.) In the case of development on a desktop workstation with remote targeting of an HP-UX server, it is important to choose an IDE that supports a remote connection to HP-UX. While most IDEs are known to support such a remote connection by means of the Java-standard JPDA interface, HP has worked closely with specific IDE vendors to ensure that their products function well with the HP Java™ Virtual Machine on HP-UX. 6 Introduction Recommended IDE tools for this environment are Together ControlCenter and Metrowerks' Code Warrior One advantage of development on a Windows (or Linux or Unix) desktop workstation with remote targeting is that these desktops support a large number of Java™ analysis tools that can be used to validate the source code. An excellent example of this is the Jtest product from ParaSoft. Prepare HP-UX for Java™ deployment NOTE: Installing patches and changing kernel parameters should be made only by knowledgeable HP-UX system administrators. Root access is needed for both. There are a number of HP-UX patches that have been identified as requirements for Java™ applications. A list of these patches can be found on the following web page: Patch Information. Install all of the patches shown for your HP-UX version and JDK version. Or you may install the most recent Quality Pack for your OS, which will reduce the number of individual patches you need to install. The Java™ environment on HP-UX requires that the kernel parameters be set to provide adequate resources for proper execution. HP has developed a free tool, Java™ Out-of-Box, which upon installation installs startup (RC) scripts, modifies kernel parameters, rebuilds the kernel, and reboots the system, thus providing better out-of-box behavior for Java™. In addition, HP has developed a free tool, HPjconfig, that will evaluate any HP-UX server to determine if it has the necessary kernel parameter settings and OS patches for Java™ applications. It uses the same lists of parameters and patches referenced above and provides simple advice on any necessary changes. It will also provide a SAM input file to allow the system administrator to make the kernel parameter changes automatically. Debugging a Java™ application There are several approaches to debugging Java™ applications. The most common methods are listed here in order of increasing sophistication. • The simplest, most popular, least expensive approach is to use system.out.println to find out what the application is doing internally. However, this is not a viable approach for an application that is running in production. • The Java™ Software Development Kit on HP-UX includes a free debugger, called JDB. It is a simple command-line tool but it does allow the developer to insert breakpoints on a per-thread basis, inspect the values of variables and attributes, modify values, and restart the application. Because of its dbx-like user interface, JDB is not particularly user-friendly. IDEs or stand-alone debugger tools are easier Prepare HP-UX for Java™ deployment 7 • • to use than JDB. However, JDB is free. For further information on JDB visit the web site www.java.sun.com/products/jdk/1.1/docs/tooldocs/solaris/jdb.html All of the IDEs contain sophisticated debuggers with graphical interfaces. They tie directly into the source code and provide excellent symbolic debugging capability. This makes them the easiest and most efficient means of debugging a Java™ program. Any of the IDEs recommended above will provide good debuggers. Remember that the choice of which IDE to use depends on whether the development is being done directly on HP-UX or with remote targeting (as described above). For debugging JNI problems (i.e., mixed Java™ and C/C++), HP provides an enhanced version of the popular Gnu Debugger (GDB, also called the Wildebeast Debugger or WDB). The HP enhancements to WDB (version 3.0.01 or later) allow it to examine backtraces containing mixed language frames in Java™ thread stacks of an application that is running on the HP Java™ Virtual Machine. For more information, refer to the SDK release notes for your Java™ version. A word of caution: the support for EJBs will probably only be found in the more expensive versions of the individual products (i.e., the "Professional" or the "Enterprise" editions of the products). Check the product feature lists before purchasing. Developing a web service The HP-UX server platform is ideally suited for hosting Web Services. Typically these services are hosted by an application server, such as BEA's WebLogic Server, a fully-featured, standards-based application server that provides the foundation on which an enterprise can build reliable, scalable, and manageable applications. Tuning a Java™ application for optimum performance Performance tuning first requires the determination of the cause of the poor performance. The problem could be due to lack of system resources and this will require changes to the kernel parameters or to the system components (memory, number of CPUs, etc.). Alternatively, it could be due to programming practices that cause unnecessary system activities (like unnecessary garbage collection). This could require changes to the program source code. HP provides a number of tools to analyze performance. These tools start at the overall application level and work progressively towards the root cause. HP OpenView Transaction Analyzer provides a comprehensive understanding of current application performance measured against service level requirements with detailed data for problem analysis. Then, the system level tools to analyze individual machine and portions of applications include GlancePlus, Prospect, top, netstat, and many others. The lower level tools include HPjmeter (-Xeprof option). For a good description of the complete list of performance tools and the appropriate usage of each of them, refer to the technical paper entitled "Java™ Profiling on HP-UX". 8 Introduction For a collection of techniques, tuning guidelines, tips and general information about Java™ performance tuning, go to the Java™ performance tuning website on DSPP. Testing for Performance and Reliability Stress testing is normally done by using tools that simulate a larger number of clients simultaneously accessing the web server and the back-end parts of the application. There are several excellent tools available that provide this load from a client platform (usually a Windows-based platform). Some highly-rated product for this task are Astra LoadTest from Mercury Interactive, SilkPerformer by Segue Software, e-Load from Empirix, and WebLoad from Rad View. During the testing, the server-side performance can be analyzed by means the tools described in the section above and the performance bottlenecks can be identified. Special considerations for cross-platform development 100% pure Java™ applications do not require a rebuild on every target platform. However, there may be other reasons why a development team may have a need to do cross-platform builds. A common reason is that a build on the target platform serves as a simple acceptance test for the target platform JDK. Another typical reason is that nightly builds in the source code management systems may be run on a platform different from the development platform. Finally, if the application has JNI code, at least the native portion needs to be built separately on each target platform. Thus, most large Java™ projects end up with a requirement of cross-platform build tools. Traditionally, teams doing cross-platform development have been required to port their build infrastructure to each target platform. For Unix systems, this meant that the developers had to customize their make files to ensure that they worked well with the indigenous version of the make. In recent years, gnumake has become a popular option that ensures cross-platform portability of make files. Some development teams have switched to shell or perl-based build scripts to ensure such portability. One of the most recent entrants in the arena of customization is Apache Ant, an initiative of the Apache Software Foundation. Apache Ant uses an XML based configuration file that defines a target tree where various tasks get executed. Instead of using shell commands for customization of dependencies, Apache Ant can be extended using Java™ classes. While Apache Ant is not the ultimate solution for all build issues, it has advantages that some projects might find compelling. The tool is 100% Java, so the tool and the customizations can be easily carried over to the target platform. The use of XML based configuration files is a definite improvement over the somewhat arcane syntax of make. Testing for Performance and Reliability 9 Source code control The source control system that is chosen should be compatible with the development tools that will be used on the project, as well as with the development platform itself (Windows, Linux, Unix). Small project teams working on Windows platforms will find Visual SourceSafe (VSS) to be a very convenient product for managing their source. VSS is available for purchase from Microsoft. However other companies provide clients that give users web access via secure connections. Alternatively, CVS (Concurrent Versions System) is an Open Source product. CVS runs on Windows, Linux, and Unix systems (including HP-UX) and also provides cross-system capabilities. Larger projects will need the extended features of Rational ClearCase. This product is available from IBM and there are versions that run on Windows or Unix. It is possible to run the ClearCase View Server and VOB Server on Unix with a client interface running on Windows and interfacing with the desktop development tools. The table shown below lists the tools that are available with each of these source control systems. This table was accurate at the time of writing this paper, however support by the individual systems changes over time and should be verified with the individual tool and control system vendors prior to purchase. Tool Desktop/Server Works with (IDEs) Visual SourceSafe (VSS) Both VisualCafe, JBuilder 5.0, ControlCenter, CodeWarrier Concurrent Versions System (CVS) Server JBuilder 5.0, ControlCenter, CodeWarrior Rational ClearCase Server VisualCafe JBuilder 4.0, ControlCenter, CodeWarrier Monitoring an enterprise application HP's OpenView product product is designed to monitor an application without adding any measurable overhead or otherwise perturbing the operation. Therefore, it can be used to monitor an environment on an ongoing basis as part of the normal systems operation. HP OpenView is an award-winning system monitoring and control product that is able to measure and report on all aspects of a systems operation. OpenView uses specific interfaces to networking software, controllers, and other components of the application infrastructure to monitor the flow of transactions as well as the traffic load to identify bottlenecks. The information is displayed on the OpenView management console, which provides options to filter the information and to respond to the findings by controlling key infrastructure parameters. For more information on the OpenView family of products, visit the web page at http://www.openview.hp.com/. 10 Introduction 2 Development Tools to Deploy Applications on HP-UX Development Lifecycle HP has developed a number of tools to simplify the development and deployment of applications on HP-UX systems. In addition, HP has established partnerships with leading tool vendors to make the best-in-class tools available for use with HP-UX. These tools cover the complete development lifecycle. This section provides a list of recommended tools along with a brief description of its usage (in engineering terms) as well as a link to the partner or HP web site that contains detailed product information. Development Tools Borland Together ControlCenter Borland Together ControlCenter is the Model-Build-Deploy Platform that you can use to develop, code, and debug Java™ applications for deployment on HP-UX. It provides Unified Modeling Language (UML) modeling, diagrams, and building block components, and many other development features, as well as deployment functionality. ControlCenter's open architecture enables it to integrate many complementary technologies. This flexibility extends functionality and allows developers to work with their favorite products from within ControlCenter. Together ControlCenter runs on Windows 95, 98, 2000 and NT, Linux and HP-UX Operating Systems and provides links to multiple deployment platforms, one of which is HP-UX. You can enter code using a Windows 95, 98, 2000, NT, Linux, or HP-UX operating system and then deploy it to an HP-UX server platform. Then test the code running on HP-UX by setting breakpoints, starting, stopping, and single-stepping the application directly from a window on the workstation. Version 5 or later of ControlCenter runs on the above Operating Systems and supports remote debugging of the JVM on HP-UX. Together ControlCenter provides support for all major middleware products, including BEA WebLogic Server IBM Rational Rose Developer IBM Rational Rose Developer is a full-function Unified Modeling Language (UML) tool that application architects or developers use in developing applications for HP-UX and other platforms. For additional information or to place an order, visit the IBM Rational Rose Developer Web site at http://www-306.ibm.com/software/awdtools/developer/rose/. Simplicity for Java™ Simplicity for Java™ Standard Edition by Data Representations is a low cost IDE with a rich set of features. It runs directly on HP-UX and provides code entry, graphical Development Lifecycle 11 representation of the code, code generation, and debugging using the HP JVM for HP-UX. It can also be run on NT, Linux, or several other platforms and the resulting code can be moved to HP-UX and run on the HP JVM for HP-UX. This IDE supports applets, servlets, and JavaBeans. Simplicity for Java™ Professional Edition is an advanced J2SE visual programming tool that provides everything developers need to build robust J2SE applications. Professional includes all of the features found in Simplicity for Java™: Standard Edition, plus much more. In addition to graphically building UIs using Swing, AWT and Java™ Beans, Professional provides an intuitive graphical method of integrating data into applications from any JDBC/ODBC data source. eXoDy application generation framework eXoDy dramatically accelerates the development of complex J2EE/Oracle applications running on HP-UX. Starting from an XML description of business requirements, eXoDy automatically generates the Java™ code, database table definitions, stored procedures, deployment code and documentation. The generated code is correct by construction and at the same time fully customizable, extensible and high performance. The eXoDy Framework comprises the following: • • • • an object and data modeling methodology automatic code generators a runtime library web database application design techniques eXoDy offers the following unique capabilities: • • • automation based on a high-level XML vocabulary effective elimination of the object-relational impedance mismatch issue specific targeting for web-enabled applications Because of the use of high level XML vocabulary, very little Java™ or database coding is required by application developers. eXoDy eliminates the object-relational mapping problem by adopting a unique approach based on the Proxy design pattern. eXoDy's transaction and concurrency control models are specifically developed for the stateless web environment. In addition, eXoDy provides comprehensive and automatic mechanisms for rendering the state of objects in XML to facilitate web personalization and enterprise data interchange. eXoDy is available from Agilis Software. For further information or to request an evaluation copy, please visit www.agilis-sw.com. Emacs editor Emacs is an open source editor that accepts macros to customize the display for specific uses. There is a macro (JDE) available that customizes it for Java™ code. The customization consists of color-coding tokens and formatting the code for readability. 12 Development Tools to Deploy Applications on HP-UX It requires a profile file for startup on HP-UX which can be found in this document. The emacs editor and Java™ macro can be downloaded from the following public sites: • The latest version of FSF emacs on UNIX platforms is at http://directory.fsf.org/ emacs.html • Emacs for NT can be found at http://www.gnu.org/software/emacs/windows/ ntemacs.html. This site also has a good FAQ about Emacs. Documentation can be found on the GNU Emacs website at: http://directory.fsf.org/ emacs.html. You can also get help via the Emacs> M-x zapropos and Ctl-h commands. jdb Debugger The Java™ SDK for HP-UX provides programming tools and the runtime environment for the HP-UX platform. The SDK includes a command-line debugger, jdb, to help you find and fix bugs in Java™ programs running on a local or remote Java™ interpreter. Because of its dbx-like user interface, jdb is not particularly user friendly. IDEs or stand-alone debugger tools are easier to use than jdb. Therefore, you might want to use IDE debugger tools. For additional information on jdb, visit the Web site: http://download.oracle.com/javase/ 1.4.2/docs/tooldocs/tools.html. Jtest by ParaSoft® Jtest by ParaSoft® is a unit testing tool that automatically tests any Java™ class or component without requiring you to write a single test case, harness, or stub. With the click of a button, Jtest automatically tests code construction (white-box testing), code functionality (black-box testing), and maintains code integrity (regression testing). It also helps you prevent errors with a customizable static analysis feature that lets you automatically enforce over 170 industry-respected coding standards, create and enforce any number of custom coding standards, and tailor the standards enforced to a particular project or group. Jtest runs on Windows 2000/NT, Solaris and Linux. We recommend that you use Jtest during the unit testing phase on the NT/2000, Solaris or Linux desktop prior to moving the application to HP-UX for system testing. ParaSoft Jtest is available from ParaSoft. For more information or to place an order, visit the ParaSoft web site (http://www.parasoft.com/jsp/smallbusiness/ tool_description.jsp?product=Jtest). HPjmeter HPjmeter can be used to perform tasks to optimize HP-UX 11i including identifying and diagnosing performance problems in Java™ applications running on HP-UX or on NonStop servers, improving garbage collection performance, analyzing Java heap dumps, etc. Development Tools 13 HPjmeter also features the following functionality: • Automatic problem detection and alerts • Dynamic real-time display of application behavior • Drill down into application profile metrics • Integrated, in-depth garbage collection analysis For more information on HPjmeter, see the website HPjmeter Downloads and Documentation HP TransactionVision HP TransactionVision is an end-to-end business transaction management solution. It can profile critical transactions and provide dynamic insight into your entire dynamic transaction flow, allowing you to quickly uncover bottlenecks accelerate repair times. For more information, visit the HP TransactionVision website . 14 Development Tools to Deploy Applications on HP-UX