-
Open Source Java Frameworks on NonStop User's Guide (Spring 3.1.0, Hibernate 4.1.1, MyFaces 2.0.2, Axis2/Java 1.5.2) HP Part Number: 698927-002 Published: December 2012 Edition: J06.11 and subsequent J-series RVUs and H06.22 and subsequent H-series RVUs.
-
© Copyright 2012 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, 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.
-
Contents About This Document.....................................................................................6 Supported Release Version Updates (RVUs)..................................................................................6 Intended Audience....................................................................................................................6 New and Changed Information in This Edition..............................................................................
-
Installing MyFaces Framework................................................................................................146 Prerequisites....................................................................................................................147 Downloading MyFaces Framework Libraries on Windows......................................................147 Deploying and Running Sample MyFaces Application on NonStop........................................
-
C Deploying Sample Applications on NonStop.............................................331 D Sample JDBC Configuration for Spring......................................................334 E Installing Spring Web Flow......................................................................336 Downloading Spring Web Flow Distribution on Windows..........................................................336 Copying Spring Web Flow Runtime Libraries from Windows to NonStop......................................
-
About This Document This manual provides information on how Spring, Hibernate, MyFaces, and Axis2/Java frameworks, referred to as SASH, can be used to develop applications that can run on the HP NonStop™ system.
-
• Updated the Hibernate distribution version in the “Downloading the Hibernate Distribution on Windows” (page 93) section. • Added the “Downloading Hibernate Dependency JAR Files using Gradle” (page 93) section. • Added the “Customizing the Hibernate Dialect for NonStop” (page 95) section. • Added a note and the Prerequisites for the Hibernate sample applications in the “Setting up Sample Hibernate Applications on NonStop” (page 98) section. • Updated “Connection Pooling” (page 112).
-
Appendix D: Sample JDBC Configuration for Spring This appendix describes the JDBC configuration for the Spring framework using NonStop JDBC Type 2 and JDBC Type 4 drivers. Appendix E: Installing Spring Web Flow This appendix describes the steps required to install Spring Web Flow on your NonStop system. Appendix F: Sample JDBC Configuration for Hibernate This appendix describes the JDBC configuration for the Hibernate framework using NonStop JDBC Type 2 and JDBC Type 4 drivers.
-
[ ] 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 of the list, or horizontally, enclosed in a pair of brackets and separated by vertical lines.
-
Line Spacing If the syntax of a command is too long to fit on a single line, each continuation line is indented three spaces and is separated from the preceding line by a blank line. This spacing distinguishes items in a continuation line from items in a vertical list of selections.
-
A group of items enclosed in brackets is a list of all possible items that can be displayed, of which one or none might actually be displayed. The items in the list can be arranged either vertically, with aligned brackets on each side of the list, or horizontally, enclosed in a pair of brackets and separated by vertical lines.
-
General Syntax Notation This 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 enclosed in brackets are required.
-
{, sql-expression}... An ellipsis immediately following a single syntax item indicates that you can repeat that syntax item any number of times. For example: expression-n… Punctuation Parentheses, commas, semicolons, and other symbols not previously described must be typed as shown. For example: DAY (datetime-expression) @script-file Quotation marks around a symbol such as a bracket or brace indicate the symbol is a required character that you must type as shown.
-
1 Introduction Java-based web application development has been inundated by frameworks of every kind. There is a framework available for almost every application development requirement. The effort for developing an application using the framework approach is significantly less as compared to developing an application afresh. The efficiency of Java-based Web development can be increased by using the appropriate framework.
-
NonStop provides a highly scalable servlet/JSP container to host the web applications developed using the frameworks. Because the applications are deployed on NSJSP, the Java frameworks can leverage the following advantages of NonStop: • Scalability Scalability in NSJSP refers to its ability to increase its capacity to process a large number of requests simultaneously, by adding resources, such as additional processes and logical processors, to a system.
-
2 Spring Framework Spring Overview Spring is an open source framework that you can use to develop enterprise applications. Its features and functions are packaged in different modules. It includes a lightweight container that provides a centralized, automated configuration and wiring of your application objects. NOTE: Throughout this document, Spring refers to Spring version 3.1.0. Spring includes the following: • A flexible MVC web application framework, built on core Spring functionality.
-
Spring Web Flow At times, web applications need to execute the same sequence of steps in different contexts. The Spring Web Flow can be used to implement such repetitive steps or flows because it integrates with the Spring Web Model View Control (MVC) platform to provide a flow definition language. For information about downloading and installing the Spring Web Flow, see Appendix E: Installing Spring Web Flow.
-
NOTE: NonStop TCP/IPv6 limits one process per processor to listen on any given port, while IP-CIP does not have any such restriction. However, in the RMI Service Exporter configuration the following property must be defined: 2. Spring applications accessing an SQL/MX database. Spring web applications can be configured to access an SQL/MX database through the JDBC drivers (JDBC Type 2 or JDBC Type 4 drivers). 3.
-
1. 2. “Downloading the Spring Distribution on Windows” (page 19) “Copying Spring Runtime Libraries from Windows to NonStop” (page 19) NOTE: Throughout the section, references are made to the following directories: • : The directory on the Windows system where the Spring distribution files are extracted. • : The OSS directory on the NonStop system where the Spring runtime JAR files are located.
-
OSS> jar -xvf spring_dist.jar NOTE: The sub-directories on the NonStop system must contain the same list of files as those in the \dist directory on the Windows system. The Spring runtime libraries are installed on the NonStop system. You can use these libraries to develop and run Spring applications on a NonStop system. Setting up Sample Spring Applications on NonStop The sample Spring applications (PetClinic and JPetStore) are included in the SAMPLES.zip file.
-
• For Windows system: Table 4 Softwares to be installed on the Windows system Software Download JDK version 1.6 Download from http://www.oracle.com/technetwork/java/javase/downloads/index.html and set the PATH and JAVA_HOME environment variables. Maven version 2.2.1 Download from http://maven.apache.org/download.html and set the PATH and MAVEN_HOME environment variables.
-
#------------------------------------------------------------# Properties that control the population of schema and data for a new data source # SQL/MX Settings for JDBC Type 4 Driver jdbc.driverClassName= com.tandem.t4jdbc.SQLMXDriver jdbc.url= jdbc:t4sqlmx://: jdbc.username= jdbc.password= jdbc.catalog=petcliniccat jdbc.schema=petclinicsch hibernate.dialect=org.hibernate.dialect.SqlmxDialect 3.
-
OSS> mkdir -p /spring/samples/petclinic/dbconfig For example: OSS> mkdir -p /home/sash_usr/sash/spring/samples/petclinic/dbconfig NOTE: can be any working directory. It is suggested that you create spring/samples/petclinic/dbconfig directory structure in . 3. Copy the following scripts from the \spring\samples\petclinic\src\main\resources\db\mxci\ Windows directory to the OSS directory created in Step 2: • petclinic_tables_script.
-
• Add a new pet to the system • View information about the pet's visit to the clinic JPetStore The intended users of the JPetStore sample application are Visitors and Shoppers. A Visitor is anyone who visits the site. A Shopper is an authenticated visitor who is signed in to the site. Visitors can browse the site for items of their interest. Shoppers can purchase items of their interest. NOTE: The JPetStore sample application described here uses Spring 3.0.2 version.
-
3. Build the JPetStore WAR file (org.springframework.samples.jpetstore-1.0.0-SNAPSHOT.war). 1. Go to the \spring\samples\jpetstore directory: command prompt> cd \spring\samples\jpetstore 2. Build the JPetStore web archive using the JDBC Type 2 driver or JDBC Type 4 driver. 1. Enter the following command: command prompt> mvn clean package The application WAR file (org.springframework.samples.jpetstore-1.0.0-SNAPSHOT.
-
3. Copy the following scripts from the \spring\samples\jpetstore\db\mxci Windows directory to the OSS directory created in Step 2: • jpetstore_tables_script.sql • jpetstore_dataload_script.sql NOTE: 4. • The jpetstore_tables_script.sql script creates the SQL/MX database catalog, schema, and tables for JPetStore. • The jpetstore_dataload_script.sql script loads the database with sample data. Go to the OSS directory where the jpetstore_tables_script.sql and jpetstore_dataload_script.
-
As a shopper, you can perform the following activities (including those performed by a visitor): • Enter a username and password to access your account. • Store shipping information and preferences for your use at future sessions. • Purchase the items collected in a Cart. • Provide payment information.
-
6. 7. PROPAGATION_NEVER: Does not support a current transaction; throws an exception if a current transaction exists. PROPAGATION_NESTED: If a current transaction exists, it executes within a nested transaction: otherwise, the behavior is similar to PROPAGATION_REQUIRED. This behavior is not supported on NonStop. Setting up the Sample SpringTMFAdapter on NonStop The sample SpringTMFAdapter is included along with the Spring application. springtmf.
-
Table 6 Softwares to be installed on the Windows system Software Download JDK version 1.6 Download from http://www.oracle.com/technetwork/java/javase/downloads/index.html and set the PATH and JAVA_HOME environment variables. JDBC Type 4 driver version For information on installing JDBC Type 4 driver on a Windows system, see JDBC Type 4 Driver Programmer's Reference for SQL/MX. Ant 1.8.2 Download from http://archive.apache.org/dist/ant/binaries/ and set the PATH and ANT_HOME environment variables.
-
Dependent Libraries for the Sample TMFAdapter Before executing the sample TMFAdapter application, get the following libraries to the \Samples\TMF_Adapter_Sample\lib directory on Windows. Then transfer these files (via FTP) to the /spring/samples/TMFAdapter/lib/ directory on the NonStop system. Table 7 TMFAdapter Dependent Libraries Dependency JAR Files antlr-2.7.6.jar Source Location \lib\required com.springsource.org.aopalliance-1.0. 0.
-
Table 7 TMFAdapter Dependent Libraries (continued) Dependency JAR Files Source Location slf4j-api-1.6.1.jar \lib\required springtmf.jar \SpringTMFAdapter t4sqlmx.jar tmf.jar /jre/lib/ext util.jar jdbcMx.jar /lib Running TMFAdapter on NonStop To run the TMFAdapter application, you can use either JDBC Type 2 driver or JDBC Type 4 driver.
-
-Djava.library.path= -Djdbcmx.transactionMode=external com.hp.programmatic.MainProgrammatic where is the location where the JDBC T2 driver is installed. For example, java -cp "/home/sash_usr/spring/samples/TMFAdapter/TMFAdapter_Sample_Programmatic.jar: /home/sash_usr/spring/samples/TMFAdapter/lib/*" -Djava.library.path=/usr/tandem/jdbcMx/current/lib -Djdbcmx.transactionMode=external com.hp.programmatic.
-
For example, java -cp "/home/sash_usr/spring/samples/TMFAdapter/TMFAdapter_Sample_Programmatic.jar: /home/sash_usr/spring/samples/TMFAdapter/lib/*" com.hp.programmatic.MainProgrammatic Annotation: java -cp "/spring/samples/TMFAdapter/TMFAdapter_Sample_Annotation.jar:/spring/samples/TMFAdapter/lib/*" com.hp.annotation.MainAnnotation AOP: java -cp "/spring/samples/TMFAdapter/TMFAdapter_Sample_AOP.
-
Configuring Spring Applications on NonStop Systems This section provides information about configuring Spring applications on NonStop systems.
-
For Type 4 Driver: Specify the username and password of your NonStop system. jdbc.username= jdbc.password= Configurations in the applicationContext.xml File Defining the Placeholder for JDBC Driver Class For JDBC Type 2 driver: HP recommends to use com.tandem.sqlmx.SQLMXDataSource as the datasource class. This datasource can be configured as follows: PAGE 36
database properties specified in the applicationContext.xml file with the values specified in the jdbc.properties file during runtime. Modify the applicationContext.xml file for wiring the jdbc.properties file as shown below: classpath:jdbc.
-
The POJO Class SimpleService can use @Transactional annotation on its methods. The SimpleService class using the @Transactional annotation is as shown: public class SimpleService { @Transactional public void addRecord(SimpleBean b){ // } public SimpleBean[] getRecords(){ // return null; } } In this case, when the addRecord transaction is invoked, it is invoked under a TMF transaction.
-
Configuring Using the Transaction Template The following configuration shows how TmfTransactionManager can be used in a Spring Transaction Template: ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“txbean.xml"); transactionTemplate = new TransactionTemplate(transactionManager); transactionTemplate.
-
Prerequisites • For NonStop system: Table 8 Softwares to be installed on the NonStop system Software For more information: NonStop iTP WebServer version 7.x or later For information on installing and setting up iTP WebServer (secure and non-secure) on a NonStop system, see the iTP Secure WebServer System Administrator's Guide. NSJSP version 6.1 For information on installing and setting up NSJSP on a NonStop system, see the NonStop Servlets for JavaServer Pages (NSJSP) 6.1 System Administrator's Guide.
-
The following sections describe the steps required to develop, deploy, and run the EmpInfo application. • “Developing EmpInfo on Windows using the Eclipse Galileo IDE” (page 40) • “Deploying EmpInfo on NonStop” (page 87) • “Running EmpInfo on NonStop” (page 89) Developing EmpInfo on Windows using the Eclipse Galileo IDE NOTE: • It is not mandatory for you to use the Eclipse Galileo IDE. You can use any IDE that supports Java.
-
2. Click OK. The Eclipse SDK Welcome screen appears. NOTE: D:\sash_usr\spring is the sample workspace used to develop the EmpInfo application. Figure 3 Eclipse SDK Welcome Screen Developing a Basic EmpInfo Application Developing the EmpInfo application using Eclipse Galileo IDE involves the following activities: 1. “Creating a Dynamic Web Project” (page 41) 2. “Creating the index.jsp File” (page 43) 3. “Modifying the index.jsp File” (page 46) 4. “Modifying the web.xml File” (page 47) 5.
-
Figure 4 New Project Wizard Dialog Box The New Dynamic Web Project dialog box appears. 3. In the Project name field, type EmpInfo and click Finish. NOTE: The other fields in the New Dynamic Web Project dialog box are selected by default.
-
When prompted, change the perspective to Java EE and click Yes to open the new perspective. NOTE: The perspective must be changed to Java EE because the Dynamic Web Project is associated with the Java EE perspective. The Project Structure appears. 4. In the Project Structure, ensure that the JRE System Library is set to JRE version 1.6 or later, as shown in Figure 6. If the JRE version is not set to 1.6, right-click JRE System Library to select JRE 1.6. NOTE: The JRE version used in this example is 1.6.
-
Figure 7 New File Dialog Box The New JavaServer Page dialog box appears. 3. 44 In the File name field, type index and ensure that the parent folder is set to EmpInfo/WebContent. Click Next.
-
Figure 8 New JavaServer Page Dialog Box The New JavaServer Page: Select JSP Template dialog box appears. 4. From the Select JSP Template dialog box, select New JSP File (html) and click Finish. NOTE: The Use JSP Template check box is selected by default.
-
Figure 9 New JavaServer Page: JSP Template Dialog Box The template for the index.jsp file is generated. Modifying the index.jsp File Add the header item and body content in the JSP file as shown: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> PAGE 47
Welcome to the EmpInfo Application
This is EmpInfo Test Page.