492
Open Source Java Frameworks on NonStop User's Guide HP Part Number: 576269-001 Published: August 2009 Edition: J06.03 and subsequent J-series RVUs and H06.06 and subsequent H-series RVUs

Open Source Java Frameworks on NonStop User's Guideh20628. · TableofContents AboutThisDocument.....15 SupportedReleaseVersionUpdates(RVUs).....15

Embed Size (px)

Citation preview

  • Open Source Java Frameworks on NonStopUser's Guide

    HP Part Number: 576269-001Published: August 2009Edition: J06.03 and subsequent J-series RVUs and H06.06 and subsequent H-series RVUs

  • Copyright 2009 Hewlett-Packard Development Company, L.P.

    Legal Notice

    Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, CommercialComputer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government undervendors 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 expresswarranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HPshall not be liable for technical or editorial errors or omissions contained herein.

    Export of the information contained in this publication may require authorization from the U.S. Department of Commerce.

    Microsoft, Windows, and Windows NT are U.S. registered trademarks of Microsoft Corporation.

    Intel, Pentium, and Celeron are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and othercountries.

    Java is a U.S. trademark of Sun Microsystems, Inc.

    Motif, OSF/1, UNIX, X/Open, and the "X" device are registered trademarks, and IT DialTone and The Open Group are trademarks of The OpenGroup in the U.S. and other countries.

    Open Software Foundation, OSF, the OSF logo, OSF/1, OSF/Motif, and Motif are trademarks of the Open Software Foundation, Inc. OSF MAKESNO WARRANTY OF ANY KIND WITH REGARD TO THE OSF MATERIAL PROVIDED HEREIN, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. OSF shall not be liable for errors containedherein or for incidental consequential damages in connection with the furnishing, performance, or use of this material.

    MyFaces and Axis2 are registered trademarks of the Apache Software Foundation.

    JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.

    Spring Framework is an open source project and is a trademark of Interface 21.

    1990, 1991, 1992, 1993 Open Software Foundation, Inc. The OSF documentation and the OSF software to which it relates are derived in partfrom materials supplied by the following: 1987, 1988, 1989 Carnegie-Mellon University. 1989, 1990, 1991 Digital Equipment Corporation. 1985, 1988, 1989, 1990 Encore Computer Corporation. 1988 Free Software Foundation, Inc. 1987, 1988, 1989, 1990, 1991 Hewlett-PackardCompany. 1985, 1987, 1988, 1989, 1990, 1991, 1992 International Business Machines Corporation. 1988, 1989 Massachusetts Institute ofTechnology. 1988, 1989, 1990 Mentat Inc. 1988 Microsoft Corporation. 1987, 1988, 1989, 1990, 1991, 1992 SecureWare, Inc. 1990, 1991Siemens Nixdorf Informationssysteme AG. 1986, 1989, 1996, 1997 Sun Microsystems, Inc. 1989, 1990, 1991 Transarc Corporation.OSF softwareand documentation are based in part on the Fourth Berkeley Software Distribution under license from The Regents of the University of California.OSF acknowledges the following individuals and institutions for their role in its development: Kenneth C.R.C. Arnold, Gregory S. Couch, ConradC. Huang, Ed James, Symmetric Computer Systems, Robert Elz. 1980, 1981, 1982, 1983, 1985, 1986, 1987, 1988, 1989 Regents of the Universityof California.

  • Table of Contents

    About This Document.......................................................................................................15Supported Release Version Updates (RVUs)........................................................................................15Intended Audience................................................................................................................................15New and Changed Information in This Edition...................................................................................15Document Organization.......................................................................................................................15Notation Conventions...........................................................................................................................17

    General Syntax Notation.................................................................................................................17Notation for Messages.....................................................................................................................19Notation for Management Programming Interfaces.......................................................................20General Syntax Notation.................................................................................................................21

    Related Information..............................................................................................................................22Publishing History................................................................................................................................22HP Encourages Your Comments..........................................................................................................23

    1 Introduction...................................................................................................................25Prerequisites..........................................................................................................................................26

    NonStop System..............................................................................................................................26NonStop iTP WebServer.............................................................................................................26NonStop Servlets for Java Server Pages (NSJSP).......................................................................28JDBC Type 2 Driver for NonStop SQL/MX................................................................................29NonStop SQL/MX.......................................................................................................................30NonStop Server for Java (NSJ)...................................................................................................30

    Windows System.............................................................................................................................31Java Development Kit (JDK)......................................................................................................31Ant..............................................................................................................................................32JDBC Type 4 Driver for NonStop SQL/MX................................................................................33Eclipse IDE.................................................................................................................................33

    I Spring Framework.........................................................................................................35

    2 Spring Overview......................................................................................................37Spring Framework Architecture......................................................................................................37Components in a Spring Application on NonStop.........................................................................39

    Web Clients.................................................................................................................................39TCP/IP Subsystem......................................................................................................................39TS/MP PATHMON Process........................................................................................................39iTP WebServer............................................................................................................................40NonStop Servlets for JavaServer Pages .....................................................................................40JDBC Drivers for NonStop SQL/MX..........................................................................................40NonStop SQL/MX.......................................................................................................................40

    Message Flow in a Spring Application on NonStop.......................................................................40Key Features of Spring....................................................................................................................42Spring Projects.................................................................................................................................42

    Spring Web Flow........................................................................................................................42

    3 Installing Spring Framework...................................................................................45Prerequisites....................................................................................................................................45

    NonStop System.........................................................................................................................45

    Table of Contents 3

  • Windows System........................................................................................................................45Installing Spring Framework Libraries on NonStop.......................................................................45

    Downloading Spring Distribution on Windows........................................................................45Copying Spring Runtime Libraries from Windows to NonStop...............................................46

    Deploying and Running Sample Spring Applications on NonStop...............................................47PetClinic.....................................................................................................................................48

    Building PetClinic on Windows............................................................................................48Setting up PetClinic Database on NonStop..........................................................................50Deploying PetClinic on NonStop..........................................................................................51Running PetClinic on NonStop.............................................................................................53

    JPetStore.....................................................................................................................................54Building JPetStore on Windows............................................................................................54Setting up JPetStore Database on NonStop..........................................................................55Deploying JPetStore on NonStop..........................................................................................57Running JPetStore on NonStop.............................................................................................58

    ImageDB.....................................................................................................................................59Building ImageDB on Windows...........................................................................................59Setting up ImageDB Database on NonStop..........................................................................61Deploying ImageDB on NonStop.........................................................................................62Running ImageDB on NonStop............................................................................................64

    4 Configuring Spring Applications on NonStop Systems.......................................65NonStop Platform Configurations..................................................................................................65

    Determining the Application Parameters..................................................................................65Determining the Maximum Capacity of NSJSP Instance..........................................................65Configuring iTP WebServer for Spring Applications................................................................66

    Configuring httpd Processes to Handle Maximum Load..................................................67Limiting the Maximum Number of Incoming Requests......................................................69

    Configuring NSJSP for Spring Applications..............................................................................70Configuring SessionBasedLoadBalancing............................................................................70Configuring Connector Threads...........................................................................................72

    Configuring the Connector Element............................................................................72Configuring the Executor Element...............................................................................73

    Configuring TS/MP Specific Parameters..............................................................................73NSJSP Configured with SessionBasedLoadBalancing Turned OFF.......................73NSJSP Configured with SessionBasedLoadBalancing Turned ON........................74

    Configuring Java Runtime Arguments.................................................................................75-Xmx.................................................................................................................................75-Xss...................................................................................................................................75-Xnoclassgc......................................................................................................................76

    Spring Framework Configurations.................................................................................................76Configuring JDBC Driver for SQL/MX Database......................................................................76

    Configuring JDBC Type 2 Driver for SQL/MX Database.....................................................76Configurations in the jdbc.properties File..............................................................76Configurations in the applicationContext.xml File...............................................77

    Configuring JDBC Type 4 Driver for SQL/MX Database.....................................................78Configurations in the jdbc.properties File..............................................................78Configurations in the applicationContext.xml File...............................................79

    Configuring Database Transaction Management......................................................................80Declarative Transaction Management..................................................................................80

    Defining the Transactional Object...................................................................................80Defining the Transactional Advice..................................................................................81Defining the Transactional Execution Point....................................................................82Defining the Transaction Datasource..............................................................................82

    4 Table of Contents

  • Defining the PlatformTransactionManager...........................................................83Defining the Transaction Rollback (Optional).................................................................83

    Programmatic Transaction Management..............................................................................84Using the TransactionTemplate...............................................................................84Using a PlatformTransactionManager...................................................................84

    Recommendation..................................................................................................................85Connection Pooling....................................................................................................................85

    Connection Pooling using Apache C3P0..............................................................................85Recommendations.................................................................................................................86

    Tuning Connection Pool..................................................................................................86Module File Caching Configurations..............................................................................................87

    Configuring NonStop SQL/MX DataSource for MFC...............................................................87Modifying the Spring Application.............................................................................................88

    5 Getting Started with Spring....................................................................................89Prerequisites....................................................................................................................................89

    NonStop System.........................................................................................................................89Windows System........................................................................................................................89

    Overview of EmpInfo......................................................................................................................89Developing EmpInfo on Windows using the Eclipse IDE.........................................................90

    Developing a Basic EmpInfo Application.............................................................................91Creating a Dynamic Web Project.....................................................................................91Creating the index.jsp File..........................................................................................95Modifying the index.jsp File.......................................................................................98Modifying the web.xml File...........................................................................................99Creating the EmpInfo-servlet.xml File..................................................................101Adding Dependency JAR Files in the Project Library Path..........................................104Creating the Controller for EmpInfo.............................................................................106Creating the View..........................................................................................................109

    Developing and Configuring Views and the Controller....................................................110Configuring the JSP Standard Tag Library....................................................................110Adding JSTL and JSP Related Dependency JARs.........................................................113Enhancing the Controller...............................................................................................113Decoupling View from the Controller...........................................................................116

    Developing Business Logic and Providing the Web Interface............................................117Creating a Simple POJO................................................................................................118Creating Data Access Object Implementation for JDBC...............................................118Creating and Modifying Supporting Views to Display Business Data.........................119Adding Dependency JAR Files......................................................................................120

    Integrating the Web-tier of EmpInfo with NonStop SQL/MX Database............................121Creating the applicationContext.xml File...........................................................121Creating the jdbc.properties File...........................................................................122Modifying the EmpInfo-servlet.xml File...............................................................124Improving the Controller...............................................................................................125Modifying the web.xml File........................................................................................127Adding Dependency JAR Files......................................................................................127Creating Database Catalog, Schema, and Tables on NonStop......................................128

    Enabling EmpInfo to Delete and Retrieve Employee Details.............................................131Creating JSPs to Delete and Retrieve Employee Details...............................................131Creating the RowMapper Class.....................................................................................133Modifying the EmployeeDao.java Class File......................................................134Modifying the Employee.java File...........................................................................134Modifying the EmployeeController.java File......................................................135Modifying the EmpInfo-servlet.xml File.............................................................136

    Table of Contents 5

  • Modifying the index.jsp File.....................................................................................137Deploying EmpInfo on NonStop.............................................................................................142

    Creating the Application WAR File on Windows...............................................................142Deploying the EmpInfo WAR File in NSJSP on NonStop..................................................143

    Running EmpInfo on NonStop................................................................................................145

    A EmpInfo Database Script.....................................................................................147

    B Customizing Sample Applications.......................................................................149Customizing PetClinic...................................................................................................................149

    Added Directory.......................................................................................................................149/etc....................................................................................................................................149

    Added File................................................................................................................................149SetDatabase.java..........................................................................................................149

    Modified Files...........................................................................................................................150build_jdbct2.xml..................................................................................................................150build_jdbct4.xml..................................................................................................................151web.xml...............................................................................................................................153petclinic.hbm.xml................................................................................................................154applicationContext-hibernate.xml......................................................................................154jdbc.properties.....................................................................................................................155

    Customizing JPetStore...................................................................................................................156Added File................................................................................................................................156

    SetDatabase.java..................................................................................................................156Modified Files...........................................................................................................................156

    build_jdbct2.xml..................................................................................................................156build_jdbct4.xml..................................................................................................................157Item.xml..............................................................................................................................158dataAccessContext-local.xml..............................................................................................158jdbc.properties.....................................................................................................................159Order.xml............................................................................................................................160

    Customizing ImageDB...................................................................................................................160Modified Files...........................................................................................................................160

    build_jdbct2.xml..................................................................................................................160build_jdbct4.xml..................................................................................................................161applicationContext.xml.......................................................................................................162schedulingContext-quartz.xml...........................................................................................162jdbc.properties.....................................................................................................................163ImageController.java...........................................................................................................164ImageDatabase.java.............................................................................................................164DefaultImageDatabase.java................................................................................................165

    C JDBC Configuration..............................................................................................167

    D Installing Spring Web Flow.................................................................................169Downloading Spring Web Flow Distribution on Windows..........................................................169Copying Spring Web Flow Runtime Libraries from Windows to NonStop.................................169

    II Axis2/Java Framework..............................................................................................171

    6 Table of Contents

  • 6 Axis2/Java Overview...........................................................................................173Axis2/Java Architecture.................................................................................................................173Key Features of Axis2/Java............................................................................................................174Components in an Axis2/Java Application on NonStop...............................................................175

    Web Clients...............................................................................................................................175TCP/IP Subsystem....................................................................................................................175TS/MP PATHMON Process......................................................................................................175iTP WebServer..........................................................................................................................175NonStop Servlets for JavaServer Pages....................................................................................176

    Message Flow in an Axis2/Java Application on NonStop.............................................................176

    7 Installing Axis2/Java Framework........................................................................179Prerequisites..................................................................................................................................179

    NonStop System.......................................................................................................................179Windows System......................................................................................................................179

    Installing Axis2/Java on NonStop..................................................................................................179Downloading Axis2/Java Distribution on Windows...............................................................179Building Axis2/Java Web Archive using Standard Binary Distribution..................................180Deploying Axis2/Java as a Web Application on NonStop.......................................................181Running Axis2/Java on NonStop.............................................................................................182

    Deploying and Running Axis2/Java Sample Applications on NonStop.......................................184FaultHandling..........................................................................................................................184

    Building FaultHandling on Windows................................................................................185Deploying FaultHandling on NonStop..............................................................................185Running FaultHandling......................................................................................................185

    MTOM......................................................................................................................................186Building MTOM on Windows............................................................................................186Deploying MTOM on NonStop..........................................................................................187Configuring the client for running MTOM.........................................................................187Running MTOM..................................................................................................................187

    8 Configuring Axis2/Java Applications on NonStop Systems............................189NonStop Platform Configurations.................................................................................................189

    Determining the Application Parameters................................................................................189Determining the Maximum Capacity of an NSJSP Instance....................................................189Configuring iTP WebServer for Axis2/Java Applications........................................................190

    Configuring httpd Processes to Handle Maximum Load................................................191Limiting the Maximum Number of Incoming Requests....................................................193

    Configuring NSJSP for Axis2/Java Applications......................................................................194Configuring SessionBasedLoadBalancing.................................................................194Configuring Connector Threads.........................................................................................196

    Configuring the Connector Element...........................................................................196Configuring the Executor Element.............................................................................196

    Configuring TS/MP Specific Parameters.............................................................................197NSJSP configured with SessionBasedLoadBalancing turned OFF.......................197NSJSP is configured with SessionBasedLoadBalancing turned ON....................198

    Configuring Java Runtime Arguments...............................................................................199-Xmx...............................................................................................................................199-Xss...............................................................................................................................199-Xnoclassgc...............................................................................................................199

    Axis2/Java Framework Configurations for NonStop Systems......................................................199Global Configuration................................................................................................................199Service Configuration...............................................................................................................200

    Table of Contents 7

  • Module Configuration..............................................................................................................200

    9 Getting Started with Axis2/Java.........................................................................201Prerequisites..................................................................................................................................201

    NonStop System.......................................................................................................................201Windows System......................................................................................................................201

    Overview of TemperatureConverter.............................................................................................201Developing TemperatureConverter Web Service on Windows...............................................201

    Creating the Web Service Implementation Class................................................................202Creating the Deployment Descriptor..................................................................................203Creating an Axis2/Java AAR File...................................................................................204

    Deploying TemperatureConverter Web Service on NonStop..................................................204Running TemperatureConverter Web Service on NonStop.....................................................205Developing TemperatureConverter Client on Windows using the Eclipse IDE.....................207

    Creating the Client Project in Eclipse..................................................................................207Creating the Java Package for Client Project.......................................................................210Creating the Class Files under the Java Package................................................................211Modifying the Class File of the Client................................................................................212Adding Dependency JAR Files...........................................................................................214

    Running TemperatureConverter Client on Windows..............................................................217

    III MyFaces Framework.................................................................................................221

    10 MyFaces Overview.............................................................................................223MyFaces Architecture ...................................................................................................................223Components in a MyFaces Application on NonStop....................................................................224

    Web Clients...............................................................................................................................224TCP/IP Subsystem....................................................................................................................224TS/MP PATHMON Process......................................................................................................224iTP WebServer..........................................................................................................................224NonStop Servlets for JavaServer Pages....................................................................................225

    Message Flow in a MyFaces Application on NonStop..................................................................225Key Features of MyFaces...............................................................................................................226MyFaces Projects............................................................................................................................227

    MyFaces Trinidad.....................................................................................................................227MyFaces Tomahawk.................................................................................................................227

    11 Installing MyFaces Framework...........................................................................229Prerequisites..................................................................................................................................229

    NonStop System.......................................................................................................................229Windows System......................................................................................................................229

    Installing MyFaces Framework Libraries on NonStop..................................................................229Downloading MyFaces Core Distribution on Windows..........................................................229Copying MyFaces Core Runtime Libraries from Windows to NonStop.................................230

    Deploying and Running Sample MyFaces Application on NonStop...........................................230myfaces-components................................................................................................................231

    Downloading Dependency JAR Files on Windows............................................................231Building myfaces-components on Windows......................................................................233Deploying myfaces-components on NonStop....................................................................234Running myfaces-components on NonStop.......................................................................235

    8 Table of Contents

  • 12 Configuring MyFaces Applications on NonStop Systems..............................239NonStop Platform Configurations.................................................................................................239

    Determining the Application Parameters................................................................................239Determining the Maximum Capacity of NSJSP Instance.........................................................239Configuring iTP WebServer for MyFaces Applications...........................................................240

    Configuring httpd Processes to Handle Maximum Load................................................241Limiting the Maximum Number of Incoming Requests....................................................243

    Configuring NSJSP for MyFaces Applications.........................................................................244Configuring SessionBasedLoadBalancing.................................................................244Configuring Connector Threads.........................................................................................246

    Configuring the Connector Element...........................................................................246Configuring the Executor Element.............................................................................246

    Configuring TS/MP Specific Parameters.............................................................................247NSJSP configured with SessionBasedLoadBalancing turned OFF.......................247NSJSP is configured with SessionBasedLoadBalancing turned ON....................248

    Configuring Java Runtime Arguments...............................................................................249-Xmx...............................................................................................................................249-Xss...............................................................................................................................249-Xnoclassgc...............................................................................................................249

    Determining the Maximum Capacity of NSJSP Instance...................................................249

    13 Getting Started with MyFaces............................................................................251Prerequisites..................................................................................................................................251

    NonStop System.......................................................................................................................251Windows System......................................................................................................................251

    Overview of SkinSelector...............................................................................................................251Developing SkinSelector on Windows using the Eclipse IDE.................................................251

    Creating a Dynamic Web Project........................................................................................253Creating the index.jsp File.............................................................................................257Modifying the web.xml File..............................................................................................259Adding Dependency JAR Files to the Project Library........................................................261Creating Views for SkinSelector..........................................................................................264

    Creating the css and results Folder................................................................................264Creating the style.css File.......................................................................................265Modifying the style.css File.....................................................................................266Creating the customize.jsp File...............................................................................267Modifying the customize.jsp File............................................................................267Creating the same-color.jsp and show-preview.jsp Files.......................................268Modifying the same-color.jsp File..........................................................................268Modifying the show-preview.jsp File.....................................................................269

    Creating the Managed Beans..............................................................................................270Creating a New Package................................................................................................270Creating a New Java Class File......................................................................................271Modifying the Java Class File........................................................................................272

    Creating the Configuration File..........................................................................................274Deploying SkinSelector on NonStop........................................................................................277

    Creating the SkinSelector Application WAR File on Windows..........................................277Deploying the SkinSelector WAR File in NSJSP on NonStop.............................................279

    Running SkinSelector on NonStop...........................................................................................280

    E Installing MyFaces Trinidad Framework Libraries on NonStop........................283Downloading MyFaces Trinidad Distribution..............................................................................283Copying MyFaces Trinidad Runtime Libraries from Windows to NonStop................................283

    Table of Contents 9

  • F Installing MyFaces Tomahawk Framework Libraries on NonStop....................285Downloading MyFaces Tomahawk Distribution on Windows.....................................................285Copying MyFaces Tomahawk Runtime Libraries from Windows to NonStop............................285

    IV Hibernate Framework...............................................................................................287

    14 Hibernate Overview............................................................................................289Hibernate Architecture..................................................................................................................289Components in a Hibernate Application on NonStop..................................................................290

    Running Hibernate as a Standalone Application.....................................................................290Clients..................................................................................................................................291JDBC Drivers for NonStop SQL/MX...................................................................................291NonStop SQL/MX...............................................................................................................291

    Running Hibernate as a Web Application................................................................................291Web Clients.........................................................................................................................291TCP/IP Subsystem...............................................................................................................291TS/MP PATHMON Process.................................................................................................292iTP WebServer.....................................................................................................................292NonStop Servlets for JavaServer Pages...............................................................................292JDBC drivers for NonStop SQL/MX....................................................................................292NonStop SQL/MX...............................................................................................................292

    Message Flow in a Hibernate Application on NonStop................................................................292Running Hibernate as a Standalone Application.....................................................................292Running Hibernate as a Web Application................................................................................293

    Key Features of Hibernate.............................................................................................................295Hibernate Projects..........................................................................................................................295

    Hibernate Annotations.............................................................................................................296Hibernate EntityManager.........................................................................................................296

    15 Installing Hibernate Framework.........................................................................297Prerequisites..................................................................................................................................297

    NonStop system.......................................................................................................................297Windows system......................................................................................................................297

    Installing Hibernate Framework Libraries on NonStop................................................................297Downloading Hibernate Distribution on Windows................................................................297Including Hibernate Dialect for the SQL/MX database to the Hibernate Distribution...........298Copying Hibernate Distribution from Windows to NonStop.................................................299

    Deploying and Running Sample Hibernate Application on NonStop.........................................299Caveat Emptor..........................................................................................................................300

    Building Caveat Emptor on Windows................................................................................300Setting up the Deployment Environment on NonStop......................................................302

    Setting up SQL/MX database on NonStop....................................................................302Setting up the Hibernate and JDBC environment on NonStop.....................................303

    Deploying Caveat Emptor on NonStop..............................................................................304Running Caveat Emptor on NonStop.................................................................................304

    16 Configuring Hibernate Applications on NonStop Systems.............................307NonStop Platform Configurations.................................................................................................307

    Determining the Application Parameters................................................................................307Determining the Maximum Capacity of NSJSP Instance.........................................................307Configuring iTP WebServer for Hibernate Applications.........................................................308

    10 Table of Contents

  • Configuring httpd Processes to Handle Maximum Load................................................309Limiting the Maximum Number of Incoming Requests....................................................311

    Configuring NSJSP for Hibernate Applications.......................................................................312Configuring SessionBasedLoadBalancing..........................................................................312Configuring Connector Threads.........................................................................................314

    Configuring the Connector Element...........................................................................314Configuring the Executor Element.............................................................................315

    Configuring TS/MP Specific Parameters.............................................................................315NSJSP Configured with SessionBasedLoadBalancing Turned OFF.....................315NSJSP Configured with SessionBasedLoadBalancing Turned ON......................316

    Configuring Java Runtime Arguments...............................................................................317-Xmx...............................................................................................................................317-Xss.................................................................................................................................317-Xnoclassgc....................................................................................................................318

    Hibernate Framework Configurations for NonStop Systems.......................................................318JDBC Driver for SQL/MX Database.........................................................................................318

    Configuring the JDBC Type 2 Driver for SQL/MX Database..............................................318Configuring the JDBC Type 2 Driver for the SQL/MX Database usinghibernate.cfg.xml..................................................................................................318Configuring JDBC Type 2 Driver for SQL/MX Database usinghibernate.properties............................................................................................320

    Configuring JDBC Type 4 Driver for SQL/MX Database....................................................322Configuring JDBC Type 4 Driver for SQL/MX Database usinghibernate.cfg.xml..................................................................................................322Configuring JDBC Type 4 Driver for SQL/MX Database usinghibernate.properties............................................................................................324

    Database Transaction Management.........................................................................................326Connection Pooling..................................................................................................................327

    Module File Caching Configurations............................................................................................327Configuring NonStop SQL/MX DataSource for MFC..............................................................327Modifying the Hibernate Application......................................................................................328

    17 Getting Started with Hibernate..........................................................................329Prerequisites..................................................................................................................................329

    NonStop System.......................................................................................................................329Windows System......................................................................................................................329

    Overview of EmpIoyeeInfo............................................................................................................329Developing EmployeeInfo on Windows using the Eclipse IDE...............................................330

    Creating a New Java Project................................................................................................331Adding Dependency JAR Files to the Project Library........................................................334Creating the Package for the EmployeeInfo Application...................................................336Creating the Class File........................................................................................................337Creating the Main Class......................................................................................................339Implementing the Business Logic.......................................................................................340Creating the Hibernate Mapping File.................................................................................342Setting Hibernate Configurations.......................................................................................345

    hibernate.cfg.xml...........................................................................................................345hibernate.properties.......................................................................................................346

    Creating the EmployeeInfo Application JAR File...............................................................349Setting Up NonStop Environment...........................................................................................351Running EmployeeInfo on NonStop........................................................................................352

    Table of Contents 11

  • G Customizing Sample Application.......................................................................355Customizing Caveat Emptor.........................................................................................................355

    Modified File............................................................................................................................355Main.java ............................................................................................................................355

    Added Files...............................................................................................................................355hibernate.properties............................................................................................................355setenv..................................................................................................................................356build_jdbct2.xml..................................................................................................................357build_jdbct4.xml..................................................................................................................358Caveatemptor_script.sql.....................................................................................................359

    H JDBC Configuration..............................................................................................361

    I Hibernate Environment Setup Script.....................................................................363

    J Installing Hibernate Annotations Libraries on NonStop.....................................365Downloading Hibernate Distribution on Windows......................................................................365Copying Hibernate Distribution from Windows to NonStop.......................................................365

    K Installing Hibernate EntityManager Libraries on NonStop...............................367Downloading Hibernate Distribution on Windows......................................................................367Copying Hibernate Distribution from Windows to NonStop.......................................................367

    V Integrating Frameworks.............................................................................................369

    18 Using Spring Transaction Manager..................................................................371Why Transaction Management is required...................................................................................371Spring Transaction Management...................................................................................................371

    Declarative Transaction Management......................................................................................371Programmatic Transaction Management.................................................................................371

    Example of Using Spring Transaction Manager............................................................................371Modifying EmpInfo on Windows using Eclipse IDE...............................................................372

    Modifying EmpInfo based on the Type of Transaction......................................................373For Declarative Transaction...........................................................................................374For Programmatic Transaction......................................................................................378

    Adding Dependency JAR Files...........................................................................................380For Declarative Transaction...........................................................................................381For Programmatic Transaction......................................................................................381

    Deploying EmpInfo on NonStop.............................................................................................382Creating the Application WAR File on Windows.................................................................382Deploying the EmpInfo WAR File in NSJSP on NonStop....................................................384

    Running EmpInfo on NonStop................................................................................................385

    19 Integrating Hibernate into Spring......................................................................387Why Integrate Hibernate into Spring............................................................................................387Example of Integrating Hibernate into Spring..............................................................................387

    Modifying EmpInfo on Windows using Eclipse IDE...............................................................388Modifying the applicationContext.xml File........................................................................389Modifying the EmployeeDao.java File................................................................................391

    12 Table of Contents

  • Creating the Employee.hbm.xml File.................................................................................392Removing the EmployeeRowMapper.java File...................................................................394Adding Dependency JAR Files...........................................................................................394

    Deploying EmpInfo on NonStop.............................................................................................395Creating the EmpInfo WAR File on Windows......................................................................396Deploying the EmpInfo WAR File in NSJSP on NonStop....................................................397

    Running EmpInfo on NonStop................................................................................................399

    20 Integrating JPA with Hibernate into Spring......................................................401Why Integrate JPA with Hibernate in Spring................................................................................401Example of Integrating JPA with Hibernate into Spring...............................................................401

    Modifying EmpInfo on Windows using Eclipse IDE...............................................................402Creating the persistence.xml File........................................................................................403Creating the EntityEmployee.java File................................................................................403Modifying the applicationContext.xml File.............................................................405Modifying the EmployeeDao.java File...........................................................................406Removing the Employee.hbm.xml File...............................................................................407Adding Dependency JAR Files...........................................................................................408

    Downloading Hibernate Entity Manager......................................................................408Adding Dependency JAR Files......................................................................................408

    Deploying EmpInfo on NonStop.............................................................................................409Creating the EmpInfo WAR File on Windows......................................................................409Deploying the EmpInfo WAR File in NSJSP on NonStop....................................................411

    Running EmpInfo on NonStop................................................................................................413

    21 Integrating Axis2/Java into Spring...................................................................415Why Integrate Axis2/Java into Spring...........................................................................................415Example of Integrating Axis2/Java with Spring............................................................................415

    Modifying EmpInfo on Windows using Eclipse IDE...............................................................416Creating the SpringInit.java File....................................................................................417Creating the services.xml File.......................................................................................418Modifying the applicationContext.xml File........................................................................418Creating the build.xml File.................................................................................................419Adding Dependency JAR Files...........................................................................................420

    Deploying EmpInfo on NonStop.............................................................................................421Creating the EmpInfo AAR File on Windows....................................................................421Deploying the EmpInfo AAR File in Axis2/Java on NonStop............................................423

    Running EmpInfo Web Service on NonStop............................................................................424Developing EmpInfoClient on Windows.................................................................................425

    Creating the EmpInfoClient Project in Eclipse...................................................................425Creating the Package for EmpInfoClient............................................................................428Creating the EmpInfoClient.java File.........................................................................429Modifying the EmpInfoClient.java File......................................................................430Adding Dependency JAR Files...........................................................................................432

    Running EmpInfoClient on Windows.....................................................................................433

    22 Integrating MyFaces into Spring.......................................................................439Why Integrate MyFaces into Spring..............................................................................................439Example of Integrating MyFaces into Spring................................................................................439

    Modifying EmpInfo on Windows using Eclipse IDE...............................................................440Removing the Folders and Files from the EmpInfo Application.......................................441Modifying the web.xml File................................................................................................441

    Table of Contents 13

  • Creating the IEmployeeDao.java File..................................................................................443Modifying the EmployeeDao.java File.........................................................................444Creating the ServiceFinder.java File....................................................................................445Creating the EmpBean.java File.......................................................................................445Creating the MessageFactory.java File................................................................................448Creating the message.properties File..................................................................................449Creating views using MyFaces tag libraries.......................................................................449

    Creating Pages folder.....................................................................................................450Creating JSPs..................................................................................................................450Modifying JSPs..............................................................................................................450Creating the mycss.css File............................................................................................457

    Modifying the index.jsp File...............................................................................................458Creating the faces-config.xml File.......................................................................................459Adding Dependency JAR Files...........................................................................................460

    Deploying EmpInfo on NonStop.............................................................................................462Creating the EmpInfo WAR File on Windows......................................................................462Deploying the EmpInfo WAR File in NSJSP on NonStop....................................................464

    Running EmpInfo on NonStop................................................................................................465

    23 Frequently Asked Questions...................................................................................477

    Glossary.........................................................................................................................481

    Index...............................................................................................................................485

    14 Table of Contents

  • About This DocumentThis manual is a user manual and a reference manual. It provides information on usingOpenSource Java Frameworks on a NonStop system, and contains instructions and guidelineson install, configure, and use the following frameworks on an HP NonStop system: Spring Axis2/Java MyFaces Hibernate

    Supported Release Version Updates (RVUs)This manual supports J06.03 and all subsequent J-series RVUs, and H06.06 and all subsequentH-series RVUs, until otherwise indicated by its replacement publications.

    Intended AudienceThis manual is intended for application programmers who want to use Java-based webapplications developed using OpenSource Java Frameworks. To use this product, the readermust be familiar with iTP WebServer, NSJSP, and the NonStop SQL/MX database.

    New and Changed Information in This EditionThis is a new manual.

    Document OrganizationThis document is organized as follows:

    This chapter introduces the Spring,Axis2/Java,MyFaces,and Hibernate framework.

    Chapter 1: Introduction

    Part I describes the procedure to customize the Springframework to work on a NonStop system.

    Part I: Spring Framework

    This chapter provides an overview of the Springframework, its architecture, key features, advantages, andmessage flow.

    Chapter 2: Spring Overview

    This chapter helps you to install Spring frameworklibraries and enables you to deploy and run sample Springapplications on your NonStop system.

    Chapter 3: Installing Spring Framework

    This chapter helps you to configure a Spring applicationon your NonStop system.

    Chapter 4: Configuring Spring Applications on NonStopSystems

    This chapter helps you to develop a web application onyour Windows system using the Spring framework, anddeploy and run the web application on your NonStopsystem.

    Chapter 5: Getting Started with Spring

    This appendix contains the EmpInfo database script.Appendix A: EmpInfo Database Script

    This appendix details the customizations made in theSpring sample applications: PetClinic, JPetStore, andImageDB.

    Appendix B: Customizing Sample Applications

    This appendix describes the consolidated JDBC Type 2driver configuration and the JDBC Type 4 driverconfiguration in the applicationContext.xml andjdbc.properties files.

    Appendix C: JDBC Configuration

    Supported Release Version Updates (RVUs) 15

  • This appendix describes the steps required to installSpring Web Flow on your NonStop system.

    Appendix D: Installing Spring Web Flow

    Part II describes the procedure to customize theAxis2/Java framework to work on a NonStop system.

    Part II: Axis2/Java Framework

    This chapter provides an overview of the Axis2/Javaframework, its architecture, key features, advantages, andmessage flow.

    Chapter 6: Axis2/Java Overview

    This chapter helps you to install the Axis2/Java frameworkand enables you to develop, set up, deploy, and run theweb application and its client on your NonStop system.

    Chapter 7: Installing Axis2/Java Framework

    This chapter helps you to configure the Axis2/Javaapplication on your NonStop system.

    Chapter 8: Configuring Axis2/Java Applications onNonStop Systems

    This chapter helps you to develop a web application onyour Windows system using Axis2/Java, and deploy andrun the web application on your NonStop system.

    Chapter 9: Getting Started with Axis2/Java

    Part III describes the procedure to customize theMyFaces framework to work on a NonStop system.

    Part III: MyFaces Framework

    This chapter provides an overview of the MyFacesframework, its architecture, key features, advantages, andmessage flow.

    Chapter 10: MyFaces Overview

    This chapter helps you to install the MyFaces applicationon your NonStop system.

    Chapter 11: Installing MyFaces Framework

    This chapter helps you to configure the MyFacesapplication on your NonStop system.

    Chapter 12: Configuring MyFaces Applications onNonStop Systems

    This chapter helps you to develop a web application onyour Windows system using MyFaces, and deploy andrun the web application on your NonStop system.

    Chapter 13: Getting Started with MyFaces

    This appendix describes the steps required to installMyFaces Trinidad Framework Libraries on your NonStopsystem.

    Appendix E: Installing MyFaces Trinidad FrameworkLibraries on NonStop

    This appendix describes the steps required to installMyFaces Tomahawk Framework Libraries on yourNonStop system.

    Appendix F: Installing MyFaces Tomahawk FrameworkLibraries on NonStop

    Part IV describes the procedure to customize theHibernate framework to work on a NonStop system.

    Part IV: Hibernate Framework

    This chapter provides an overview of Hibernateframework, its architecture, key features, advantages, andmessage flow.

    Chapter 14: Hibernate Overview

    This chapter helps you to install Hibernate frameworklibraries, and enables you to deploy and run sampleHibernate application on your NonStop system.

    Chapter 15: Installing Hibernate Framework

    This chapter helps you to configure the Hibernateapplication on your NonStop system.

    Chapter 16: Configuring Hibernate Applications onNonStop Systems

    This chapter helps you to develop a web application onyour Windows system using Hibernate, and set up andrun the web application on your NonStop system.

    Chapter 17: Getting Started with Hibernate

    This appendix details the customizations made in theHibernate sample application, namely, Caveat Emptor.

    Appendix G: Customizing Sample Application

    This appendix describes the consolidated JDBC Type 2driver configuration and the JDBC Type 4 driverconfiguration in the hibernate.cfg.xml andhibernate.properties files.

    Appendix H: JDBC Configuration

    16

  • This appendix contains the ei_setenv script.Appendix I: Hibernate Environment Setup Script

    This appendix describes the steps required to installHibernate Annotations Libraries on your NonStop system.

    Appendix J: Installing Hibernate Annotations Librarieson NonStop

    This appendix describes the steps required to installHibernate EntityManager Libraries on your NonStopsystem.

    Appendix K: Installing Hibernate EntityManager Librarieson NonStop

    Part V helps you to use the SpringTransactionManagerand integrate Spring with Hibernate, Axis2/Java, andMyFaces.

    Part V: Integrating Frameworks

    This chapter helps you to use the Spring TransactionManager.

    Chapter 18: Using Spring Transaction Manager

    This chapter helps you to integrate Hibernate into theSpring framework.

    Chapter 19: Integrating Hibernate into Spring

    This chapter helps you to integrate JPA with Hibernateinto the Spring framework.

    Chapter 20: Integrating JPA with Hibernate into Spring

    This chapter helps you to integrate Axis2/Java into theSpring framework.

    Chapter 21: Integrating Axis2/Java into Spring

    This chapter helps you to integrate MyFaces into theSpring framework.

    Chapter 22: Integrating MyFaces into Spring

    This chapter provides answers to some frequently askedquestions.

    Chapter 23: Frequently Asked Questions

    Notation Conventions

    General Syntax NotationThis list summarizes the notation conventions for syntax presentation in this manual.UPPERCASE LETTERS

    Uppercase letters indicate keywords and reserved words. Type these items exactly as shown.Items not enclosed in brackets are required. For example:MAXATTACH

    Italic Letters

    Italic letters, regardless of font, indicate variable items that you supply. Items not enclosedin brackets are required. For example:file-name

    Computer Type

    Computer type letters indicate: C and Open System Services (OSS) keywords, commands, and reserved words. Type

    these items exactly as shown. Items not enclosed in brackets are required. For example:Use the cextdecs.h header file.

    Text displayed by the computer. For example:Last Logon: 14 May 2006, 08:02:23

    A listing of computer code. For exampleif (listen(sock, 1) < 0){perror("Listen Error");exit(-1);}

    Notation Conventions 17

  • Bold Text

    Bold text in an example indicates user input typed at the terminal. For example:ENTER RUN CODE

    ?123CODE RECEIVED: 123.00

    The user must press the Return key after typing the input.[ ] Brackets

    Brackets enclose optional syntax items. For example:TERM [\system-name.]$terminal-name

    INT[ERRUPTS]

    A group of items enclosed in brackets is a list from which you can choose one item or none.The items in the list can be arranged either vertically, with aligned brackets on each side ofthe list, or horizontally, enclosed in a pair of brackets and separated by vertical lines. Forexample:FC [ num ] [ -num ] [ text ]

    K [ X | D ] address

    { } BracesA group of items enclosed in braces is a list from which you are required to choose one item.The items in the list can be arranged either vertically, with aligned braces on each side of thelist, or horizontally, enclosed in a pair of braces and separated by vertical lines. For example:LISTOPENS PROCESS { $appl-mgr-name } { $process-name }

    ALLOWSU { ON | OFF }

    | Vertical LineA vertical line separates alternatives in a horizontal list that is enclosed in brackets or braces.For example:INSPECT { OFF | ON | SAVEABEND }

    EllipsisAn ellipsis immediately following a pair of brackets or braces indicates that you can repeatthe enclosed sequence of syntax items any number of times. For example:M address [ , new-value ]

    - ] {0|1|2|3|4|5|6|7|8|9}

    An ellipsis immediately following a single syntax item indicates that you can repeat thatsyntax item any number of times. For example:"s-char"

    PunctuationParentheses, commas, semicolons, and other symbols not previously described must be typedas shown. For example:error := NEXTFILENAME ( file-name ) ;

    LISTOPENS SU $process-name.#su-name

    Quotation marks around a symbol such as a bracket or brace indicate the symbol is a requiredcharacter that you must type as shown. For example:"[" repetition-constant-list "]"

    18

  • Item SpacingSpaces shown between items are required unless one of the items is a punctuation symbolsuch as a parenthesis or a comma. For example:CALL STEPMOM ( process-id ) ;

    If there is no space between two items, spaces are not permitted. In this example, no spacesare permitted between the period and any other items:$process-name.#su-name

    Line SpacingIf the syntax of a command is too long to fit on a single line, each continuation line is indentedthree spaces and is separated from the preceding line by a blank line. This spacingdistinguishes items in a continuation line from items in a vertical list of selections. For example:ALTER [ / OUT file-spec / ] LINE

    [ , attribute-spec ]

    !i and !oIn procedure calls, the !i notation follows an input parameter (one that passes data to thecalled procedure); the !o notation follows an output parameter (one that returns data to thecalling program). For example:CALL CHECKRESIZESEGMENT ( segment-id !i , error ) ; !o

    !i,oIn procedure calls, the !i,o notation follows an input/output parameter (one that both passesdata to the called procedure and returns data to the calling program). For example:error := COMPRESSEDIT ( filenum ) ; !i,o

    !i:iIn procedure calls, the !i:i notation follows an input string parameter that has a correspondingparameter specifying the length of the string in bytes. For example:error := FILENAME_COMPARE_ ( filename1:length !i:i , filename2:length ) ; !i:i

    !o:iIn procedure calls, the !o:i notation follows an output buffer parameter that has acorresponding input parameter specifying the maximum length of the output buffer in bytes.For example:error := FILE_GETINFO_ ( filenum !i , [ filename:maxlen ] ) ; !o:i

    Notation for MessagesThis list summarizes the notation conventions for the presentation of displayed messages in thismanual.Bold Text

    Bold text in an example indicates user input typed at the terminal. For example:ENTER RUN CODE

    ?123CODE RECEIVED: 123.00

    The user must press the Return key after typing the input.Nonitalic Text

    Nonitalic letters, numbers, and punctuation indicate text that is displayed or returned exactlyas shown. For example:Backup Up.

    Notation Conventions 19

  • Italic Text

    Italic text indicates variable items whose values are displayed or returned. For example:p-register

    process-name

    [ ] BracketsBrackets enclose items that are sometimes, but not always, displayed. For example:Event number = number [ Subject = first-subject-value ]

    A group of items enclosed in brackets is a list of all possible items that can be displayed, ofwhich one or none might actually be displayed. The items in the list can be arranged eithervertically, with aligned brackets on each side of the list, or horizontally, enclosed in a pair ofbrackets and separated by vertical lines. For example:proc-name trapped [ in SQL | in SQL file system ]

    { } BracesA group of items enclosed in braces is a list of all possible items that can be displayed, ofwhich one is actually displayed. The items in the list can be arranged either vertically, withaligned braces on each side of the list, or horizontally, enclosed in a pair of braces andseparated by vertical lines. For example:obj-type obj-name state changed to state, caused by{ Object | Operator | Service }

    process-name State changed from old-objstate to objstate{ Operator Request. }{ Unknown. }

    | Vertical LineA vertical line separates alternatives in a horizontal list that is enclosed in brackets or braces.For example:Transfer status: { OK | Failed }

    % Percent SignA percent sign precedes a number that is not in decimal notation. The % notation precedesan octal number. The %B notation precedes a binary number. The %H notation precedes ahexadecimal number. For example:%005400

    %B101111

    %H2F

    P=%p-register E=%e-register

    Notation for Management Programming InterfacesThis list summarizes the notation conventions used in the boxed descriptions of programmaticcommands, event messages, and error lists in this manual.UPPERCASE LETTERS

    Uppercase letters indicate names from definition files. Type these names exactly as shown.For example:ZCOM-TKN-SUBJ-SERV

    lowercase lettersWords in lowercase letters are words that are part of the notation, including Data DefinitionLanguage (DDL) keywords. For example:token-type

    20

  • !rThe !r notation following a token or field name indicates that the token or field is required.For example:ZCOM-TKN-OBJNAME token-type ZSPI-TYP-STRING. !r

    !oThe !o notation following a token or field name indicates that the token or field is optional.For example:ZSPI-TKN-MANAGER token-type ZSPI-TYP-FNAME32. !o

    General Syntax NotationThis list summarizes the notation conventions for syntax presentation in this manual.UPPERCASE LETTERS

    Uppercase letters indicate keywords and reserved words. Type these items exactly as shown.Items not enclosed in brackets are required. For example:SELECT

    Italic Letters

    Italic letters, regardless of font, indicate variable items that you supply. Items not enclosedin brackets are required. For example:file-name

    Computer Type

    Computer type letters within text indicate case-sensitive keywords and reserved words. Typethese items exactly as shown. Items not enclosed in brackets are required. For example:myfile.sh

    Bold Text

    Bold text in an example indicates user input typed at the terminal. For example:ENTER RUN CODE

    ?123CODE RECEIVED: 123.00

    The user must press the Return key after typing the input.[ ] Brackets

    Brackets enclose optional syntax items. For example:DATETIME [start-field TO] end-field

    A group of items enclosed in brackets is a list from which you can choose one item or none.The items in the list can be arranged either vertically, with aligned brackets on each side ofthe list, or horizontally, enclosed in a pair of brackets and separated by vertical lines. Forexample:DROP SCHEMA schema [CASCADE] [RESTRICT]

    DROP SCHEMA schema [ CASCADE | RESTRICT ]

    { } BracesBraces enclose required syntax items. For example:FROM { grantee[, grantee]...}

    A group of items enclosed in braces is a list from which you are required to choose one item.The items in the list can be arranged either vertically, with aligned braces on each side of thelist, or horizontally, enclosed in a pair of braces and separated by vertical lines. For example:INTERVAL { start-field TO end-field } { single-field }

    INTERVAL { start-field TO end-field | single-field }

    Notation Conventions 21

  • | Vertical LineA vertical line separates alternatives in a horizontal list that is enclosed in brackets or braces.For example:{expression | NULL}

    EllipsisAn ellipsis immediately following a pair of brackets or braces indicates that you can repeatthe enclosed sequence of syntax items any number of times. For example:ATTRIBUTE[S] attribute [, attribute]...

    {, sql-expression}...

    An ellipsis immediately following a single syntax item indicates that you can repeat thatsyntax item any number of times. For example:expression-n

    PunctuationParentheses, commas, semicolons, and other symbols not previously described must be typedas shown. For example:DAY (datetime-expression)

    @script-file

    Quotation marks around a symbol such as a bracket or brace indicate the symbol is a requiredcharacter that you must type as shown. For example:"{" module-name [, module-name]... "}"

    Item SpacingSpaces shown between items are required unless one of the items is a punctuation symbolsuch as a parenthesis or a comma. For example:DAY (datetime-expression)

    DAY(datetime-expression)

    If there is no space between two items, spaces are not permitted. In this example, no spacesare permitted between the period and any other items:myfile.sh

    Line SpacingIf the syntax of a command is too long to fit on a single line, each continuation line