Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
® Leverage Rational Application Developer v8 to develop Java EE6 application and test with WebSphere Application Server v8 Author: Ying Liu [email protected] Date: June 24, 2011 © 2011 IBM Corporation THE INFORMATION CONTAINED IN THIS REPORT IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. ALTHOUGH EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION CONTAINED IN THIS PRESENTATION, IT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN ADDITION, THIS INFORMATION IS BASED ON IBM’S CURRENT PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BYIBM WITHOUT NOTICE. IBM SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, THIS REPORT OR ANY OTHER DOCUMENTATION. NOTHING CONTAINED IN THIS REPORT IS INTENDED TO, OR SHALL HAVE THE EFFECT OF CREATING ANY WARRANTY OR REPRESENTATION FROM IBM (OR ITS AFFILIATES OR ITS OR THEIR SUPPLIERS AND/OR LICENSORS); OR ALTERING THE TERMS AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT GOVERNING THE USE OF IBM SOFTWARE. Trademarks and Service Marks The following terms are trademarks of the IBM Corporation in the United States or other countries or both: IBM WebSphere® ● IBM WebSphere Application Server ● IBM Rational® Application Developer ● Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates. Other company, product and service names may be trademarks or service marks of others. 3 Executive Summary This test scenario verified Java EE 6 application support in IBM WebSphere Application Server (WAS) V8.0 and IBM® Rational® Application Developer (RAD) V8.0.* works properly when EJB 3.1, Servlet 3.0,JPA 2.0 new features are used in enterprise application development. The scenario also verified the operations assistance to application publishing, exporting and installing works properly. Audience This report is intended for developers and administrators who want to improve development and operational capabilities over JavaEE application development and installation using Rational Application Developer (RAD) and WebSphere Application Server (WAS). Scenario Description Objective: This test case is focusing on integration test between RAD V8 and WAS V8, supporting JEE6 development. We will use RAD to develop JEE 6 application, and get it tested within a remote WAS server. Java EE 6 Simplify standards-based enterprise Java development for dept. to core business apps Enhanced developer productivity, user experiences, performance & integration: Enterprise JavaBeans (EJB) 3.1: Enhanced Java API for RESTful Web Services (JAX-RS) developer productivity through simplification including testing outside of the application server, new timer support & async enhancements Contexts and Dependency Injection for Java (CDI) 1.0: Faster time to value through tighter and simpler integration between Web & business logic tiers Java Persistence API (JPA) 2.0: Enhanced developer ease of use & app performance through improved locking, mapping support & dynamic query construction Java Servlet 3.0: Enhanced time to value through annotations and ease of integrating third party presentation frameworks 1.1: Deliver better user experiences faster through integrated Web 2.0 prog model support JavaServer Faces (JSF) 2.0: Enhanced developer productivity & end user experience through annotations & Facelets support Bean Validation 1.0: Improved developer productivity through declarative means for describing validation constraints for data Java Architecture for XML Binding (JAXB) 2.2: Improved performance via new default marshalling optimizations Enterprise Web Services 1.3: Improved integration and reuse support Java API for XML-Based Web Services (JAXWS) 2.2: Developer productivity and security enhancements Feature Highlights: The current test scenario focused on the following JEE6 capabilities ➔ ➔ ➔ ➔ Servlets3.0 - The new version uses annotations to declare the servlets and making the deployment descriptos optional. Apart from using the annotations, as a whole the specification more focused on simplifying the web tier technologies. EJB3.1 - The main goal of EJB 3.1 is to continue down the path of making EJB as simple as possible while adding meaningful business component services, new features for example: No interface local view, Singleton Bean , Timer for application server... JPA2.0 - JPA 2.0 aims to build on this success by filing in a few much needed gaps as well as adding useful innovations. It adds a number of much needed ORM mapping enhancements such as the ability to model collections, maps and lists via the annotations. EntityManager, Query APIs , JPQL are also enhanced. JPA2.0 adds a Criteria API . Bean Validation - JavaBeans Validation (Bean Validation) is a new validation model available as part of Java EE 6 platform. The Bean Validation model is supported by constraints in the form of annotations placed on a field, method, or class of a JavaBeans component, such as a backing bean. Topology – WebSphere Application Server This scenario will require one personal computer to install Rational Application Developer(RAD), and one WebSphere Application Server (WAS) stand-alone environment that will originally consist of an application server. We also need a DB2 database server for this scenario. For reference , a sample Topology used in IBM internal test work: OS # of CPUs CPU Speed CPU Type RAM (GB) Function WinXP 2 2.6 Ghz INTEL32 4 IDE Solaris 10 2 1.4 GHz SunSparc 2 Node1/server1 Red Hat Enterprise Linux Server 4 2.6 Ghz INTEL32 20 Database Application server RAD DB2 server Applications ● JavaEE6 Application “SocialSphere” (internal test application) ➔ ➔ A light weight application with users that can communicate user interaction by using new technology such as JEE6. SocialSphere includes JPA 2.0, EJB 3.1, Servlet 3.0 and Bean validation. Installation and Configuration Let's launch the installation and configuration phase now. Please use IBM Installation Manager – to perform the following installation Installation Manager is a single installation program that can use remote or local software repositories to install, modify, or update new products. It determines and shows available packages—including products, fix packs, interim fixes, and so on—checks prerequisites and interdependencies, and installs the selected packages. You also use Installation Manager to easily uninstall the packages that it installed. Steps at a glance: ➔ Install WebSphere Application Server, create required profiles. ➔ Install RAD and create connection to the profile of Application Server. Notes: ● IBM installation manager version 1.4.4 is used for installation. ● IBM RAD version 8.0.2 is used for JEE6 application development & test with WAS v8. ● Download links: ● Installation manager ● RAD trial version ● WAS Network deployment trial version Detailed Installation and Configuration - 1 1. These steps assume the database server you are using is already installed and configured. 2. Install WebSphere Application Server Network Deployment (ND) binaries on the machine to be used for WebSphere application server node by Installation manager. If you don't have experience on WebSphere Application Server installation with Installation Manager, please refer to “Installing V7 Feature Packs, Installation Manager” test report. OR, refer to WAS v8 Info center Installation topic to get more detail information. 3. Create required profile on WebSphere Application Server. An “application server” profile is recommended. The “profile management tool” will be launched after WebSphere Application Server is installed, and guide you to create a profile. Detailed Installation and Configuration - 2 4. Install RAD by Installation Manager, and select necessary package to support Java EE application development – In Installation Manager : Select the option “Tools for developing application without a local server installation” in case you need a remote application server to deploy applications. ● Select the option “JavaTM EE and Web services development tools” ● Refer to the sample screen shot on the right or refer to RAD info center installation topic for details. 5. Define a new “remote” server in RAD – Go to J2EE Perspective --> Servers -> New – Select the server type with WebSphere Application Server v8.0 Beta -> Input hostname and SOAP port of the application server – Click Finish, and Save. – You can find the SOAP port from WAS Admin Console->WebSphere application servers->server1>Communications->Ports JEE6 Application Development Procedures Now, you have finished the installation and configuration phase for Application Server and RAD. Let's proceed with execution. Next steps at a glance: To develop an enterprise application using RAD: ➔ Create new projects for EJB 3.1 modules and Servlet 3.0 Web modules ➔ Add JPA2.0 support in EJB modules ➔ Add Bean validation support in EJB modules ➔ Configure Web modules with Servlet 3.0 characteristics To deploy the application to WebSphere Application Server: ➔ Publish application from RAD to WAS ➔ Install shared libraries on WebSphere Application Server ➔ Configure DataSouce and Environment Variables Detailed Procedures - 1 1. Creating an enterprise application project Using the wizard to create an enterprise application project allows you to package many web applications and modules in a project and deploy these modules as a J2EE enterprise application. – In the JavaEE perspective, click File > New > Project; In the New Project Wizard, select Java EE > Enterprise Application Project and click Next, type a name for the new project. – In the Target runtime field, select the target runtime for the project. You can click the New button to create a new runtime for the project to use. – To use a predefined configuration for your project, select a configuration in the Configuration list. You can click the Modify button to customize project facets and Limit your project to be compatible with one or more runtimes Facets define characteristics and requirements for Java EE projects and are used as part of the runtime configuration. Detailed Procedures - 2 2. Add “EJB Project” to the enterprise application project – In RAD, Select the enterprise project created in step 1, right-click and select “New > Projects > EJB > EJB Project” – Input Project name,i.e. “SocialSphereEJB” ; Select “EJB module version” to 3.1; Click Finish then it will be added to the enterprise project by default 3. Add “Web Project” to the enterprise application project – In RAD, Select the enterprise project created in step 1, right-click and select “New > Projects > Web > Dynamic Web Project” – Input Project name, i.e “SocialSphereWeb” ; Select “Dynamic web module version” to 3.0 to use servlet3.0; Click Finish Detailed Procedures - 3 4.Make the project support JPA2.0 – Right click the EJB module SocialSphereEJB created in step2 and select “properties” in the menu. – Go to ProjectFacets -> Select JPA and set its Version to 2.0 → click OK to confirm the setting. – Then right click the EJB module again, you will find the new options in “JPA Tools” menu Detailed Procedures - 4 5. Map database tables to entities of JPA2.0 – Right click EJB project, then, “JPA tools” , then select “Generate Entities from Tables...”, and add a new DB connection in its “Connection” input. JPA tools will generate entities when the DB connection is set right, And the entities will be found in : SocialSphereEJB>JPA Content>persistence.xml Detailed Procedures – 5 5. Map database tables to entities of JPA2.0 (continue) – Right click EJB project, then, “JPA tools” , then select “Configure Project for JDBC Deployment” JPA tools will update persistentce.xml as below: Detailed Procedures - 6 6. Create Session EJB to query the entities Create a session EJB to query the entities Use the context”SocialSphere” declared in persistence.xml Create a query We can also define NamedQueries in the Entity class, and then call it in Session EJB class: Detailed Procedures - 7 7. Use the Criteria API – Create the StaticMetamodel class for the Entities – Define CriterialQuery in Session EJB using Criteria API The CommentTab_ class can be generated with com.ibm.ws.jpa.thinclient_8.0.0.jar – To create StaticMetamodel class: • Fetch com.ibm.ws.jpa.thinclient_8.0.0.jar from your WAS machine <WAS_server_root>/runtimes/ to RAD. • EJB project > properties > Java Compiler > Annotation Processing > Factory Path , add com.ibm.ws.jpa.thinclient_8.0.0.jar • EJB project > properties > Java Compiler > Annotation Processing, add the Processor options: openjpa.metamodel=true Detailed Procedures - 8 8. Use Bean Validation feature to constrain the entities – Add Bean validation mode in previous persistence.xml created in step 5 <validation-mode>AUTO</validation-mode> – Using Hibernate Validator framework to declare constraints via XML Set the constraints configuration file path in the path : METAINF/validation.xml of EJB project Set up the referenced constraints.xml Detailed Procedures - 9 9. Refer EJB in servlet using no-interface-local-view feature of EJB3.1 Define a servlet with annotation Refer the Local EJBs 10. Customize the cookie configuration using SessionCookieConfig interface – SessionCookieConfig can only be called before the servlet start – Implement and register the ServletContextListener interface to handle the configuration when the servlet first loaded – Set the fields of SessionCookieConfig – We can find that the sessionid received by the web browser becomes our customized value Detailed Procedures - 10 11. Publish applications from RAD to WAS – Go to J2EE Perspective --> Servers → Select target WAS v8.0 server , right click and select “Add and Remove” – If your WAS server is not started yet, please start the server, and select “Publish” option to synchronize the application from RAD to WAS 12. Set JDBC provider and Data source for application. – Logon WebSpere Application Server Admin concole – Visit Resource ->JDBC Providers → New JDBC Provider to configure JDBC provider information – Visit Resource ->JDBC Providers → JDBC Provider → <Provider Name> → New Data Source to configure the data source information Detailed Procedures - 11 13. Install shared library in WebSphere Application Server – Define shared library reference in WebSphere application Server to enable Hibernate Validator framework used in step 8 – Logon WebSphere application Server Admin Console, click Environment → Share Library → Select a proper scope → New: 14. Set variables to enable bean validation in WebSphere Application Server – Define WebSphere variables for ${BEAN_VALIDATION} variable used in step 13 – Logon WebSphere application Server Admin Console, click Environment → WebSphere Variable → Select a proper scope → New, add definition for variable “BEAN_VALIDATION” Results ● ● ● ● ● ● ● Install WebSphere Application Server, create required profiles. Verify WAS installation & profile generation process without error msg. [Yes] Install RAD , and create connection to the profile of Application Server. Verify remote server configuration & launching in RAD [Yes] Create new projects for EJB 3.1 modules and Servlet 3.0 Web modules. Verify EJB 3.1 modules & Servlet 3.0 web modules are generated without error msg [Yes] Add JPA2.0 support in EJB modules. Verify persistence.xml generated from tables & define different queries with different methods [Yes] Add Bean validation support in EJB modules. Verify bean validation works in sample application [Yes] Configure Web modules with Servlet 3.0 characteristics Verify Servlet 3.0 characteristics works in sample application [Yes] Install shared libraries & environment variables on WebSphere Application Server. Verify the shared libraries is loaded from the correct location once WAS is launched [Yes] Summary You have successfully deployed a Java EE6 application with IBM® Rational® Application Developer for WebSphere® Application Server. RAD helps you to quickly design, develop, analyze, test, profile, and deploy high-quality Web, service-oriented architecture (SOA), Java™, Java EE, and portal applications and publish them to application server. ● References [1] IBM WebSphere Application Server Version 8.0.0 Information Center –http://publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp [2] IBM Rational Application Developer Version 8.0.2 Information Center –http://publib.boulder.ibm.com/infocenter/radhelp/v8/index.jsp [3] IBM Education Assistant –http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/topic/com.ibm.iea.wasf posgi/plugin_coverpage.html?resultof=%22%6f%73%67%69%22%20 [4] If you want more test reports of WebSphere Application Server, please refer to: –https://www.ibm.com/developerworks/mydeveloperworks/wikis/home? lang=en#/wiki/WebSphere%20Application%20Server%20Test%20Team End This page intentionally left blank