Vikas Manoria IT Specialist – IBM Academic Initiative [email_address] m Section - 7)  Packaging and  Deployment
Section 7 -  Packaging and Deployment (9%)   Create J2EE projects  Import and export J2EE modules  Create and locate resources in the appropriate location of the project hierarchy  Work with Web and Application Deployment Descriptor Editors
What is J2EE? Enterprise application development  Specification Platform for  developing, deploying and managing  n-tier ,web-enabled ,server centric and component based enterprise application
J2EE Architecture
J2EE Multi-tier Model
J2EE Perspective Project Explorer Code Editor Resource Views
Associating Projects with a Server There are several ways to associate a project with a server: From the project context pop-up menu, select  Run As > Run on server You will be able to choose a server in the dialog, and associate the project with that server From the server context pop-up menu in the Servers view, select  Add and Remove Projects… The server will be started in order to add or remove projects From the project context pop-up menu, select  Properties > Server From here, you can set the runtime target and the default server
J2EE Packaging The J2EE specification defines standard archive formats for all J2EE components EJB module Packaged in a Java archive (.jar) file Web module Packaged in a Web archive (.war) file Application client module Packaged in a Java archive (.jar) file Resource adapter module Packaged in a resource adapter archive (.rar) file Enterprise application Packaged in an enterprise archive (.ear) file
J2EE Packaging – Containment Hierarchy web resource JSP Servlet client1.jar web1.war res1.rar EJB client class native library adapter jar ejb1.jar app1.ear ejb-jar.xml application-client.xml web.xml web resource JSP Servlet ejb1.jar client1.jar web1.war res1.rar ra.xml EJB client class native library adapter jar application.xml
EJB Module An EJB module is contained in an EJB jar file Several beans may be packaged within a single EJB jar file The EJB JAR contains all the classes required for each EJB The enterprise bean class The enterprise bean home and component interfaces The primary key class if the bean is an entity bean The deployment descriptor (ejb-jar.xml) contains: EJB structural information Defining the class names, external dependencies, persistent fields and relationships (for CMP beans) Application assembly information describing how the EJBs fit into a wider application Security information and transaction attribute
Web Module Web modules (also known as Web applications) are contained in a Web archive (.WAR) file A WAR file will normally contain several Servlets, JavaServer Pages and other Web resources For example, a Web application may contain HTML files, graphics files, audio files and movies The deployment descriptor (web.xml) contains configuration information for resources contained in the war file For example, initialization parameters, session management configuration, Servlet declarations and mappings, filter definitions, welcome file list, and error pages Security information, tag libraries, and JNDI configuration may also be provided
Application Client Module Application clients are contained in jar file An application client JAR file contains all the classes required for the client to function The deployment descriptor (application-client.xml) contains configuration information for the client The enterprise beans and external resources referenced by the application client The mechanism for deployment and installation of the application client is not specified in the J2EE specification J2EE product providers may provide an application launcher that integrates with the application client machine’s native operating system
Resource Adapter Module Resource adapters are contained in a resource adapter archive (.RAR) file A resource adapter archive RAR file contains: Java code for the resource adapter Utility Java classes for the resource adapter Platform-dependent native libraries required by the resource adapter Help files and documentation The deployment descriptor (ra.xml) contains: General information on the adapter The class names of the connection factory and implementation class Transaction and security information
Enterprise Application Enterprise applications are contained in an enterprise archive (.ear) file An enterprise archive file contains one or more J2EE modules EJB jars, wars, application client jars and rars The enterprise application deployment descriptor (application.xml) contains: Details of all the modules packages in the ear file Definitions of security roles for the enterprise application
Relationship between Projects and J2EE Packages In J2EE V1.4 there are four application component types supported by the runtime environment: Application Clients Applets Web applications (servlets, JSPs, and HTML pages) EJBs J2EE components are packaged for deployment as modules: Application client module Web application module EJB module Resource adapter module Rational Application Developer projects map to J2EE packages
J2EE Packaging Structure Review Web DD EJB Module JAR file Web Module WAR file Client Module JAR file J2EE Application EAR file Installed RARs IBM Bind Schema Map Schema Attributes Table  Creation was.policy (Java2 Sec) IBM Bind/Ext HTML, GIFs, and so on Servlet JSP Application DD Client Classes EJBs IBM Bind/Ext IBM Bind/Ext EJB DD Client DD RA DD
Data Sources Defined in Enhanced EAR Application-related properties and data sources can be defined within an application to simplify application deployment Configuration files added to the J2EE EAR file as an IBM extension Properties are used when application is installed Data source is registered with the WebSphere V6.1 server when the application is started Configuration variables can be defined for substitution with server values when application is installed Enhanced EAR Properties J2EE Enterprise Application (EAR) Components Components Resources
Other Properties Defined in the Enhanced EAR 1 2 3 4 5 6 7
Exporting Web Applications A Web application can be exported in two ways using the context menu: As an EAR file As a WAR file
Sharing Projects between Workspaces Project Interchange  is an export feature that allows the export of entire projects. The project structure is maintained, including metadata files. Unlike exporting a WAR, where you may lose metadata. Unrelated projects can be  exported. You can then  easily import the projects into another workspace with a single action.
Publishing Applications  Application Developer supports: WebSphere test environment in the development environment Tomcat test environment in the development environment WebSphere local or remote server outside the development environment Tomcat local server outside the developer environment J2EE Web publishing server Static Web publishing server
Publishing Applications  The server tools provide several publishing methods that you can use when publishing projects and files. Server Status Server Name and Type
Checkpoint What are the four application component types supported by the runtime environment? What are the four modules used to package J2EE components? Name two components of the WAR file. You have a static Web project. Which archive can you use to export it: WAR or EAR? What is one of the most common uses of the enhanced EAR? What is the difference between exporting in .zip format and in project interchange format?
Checkpoint answers The four application component types supported by the runtime environment: Application Clients, Applets, Web applications (servlets, JSPs, HTML pages, and so on), and EJBs The four module types used to package J2EE components: Application client module, Web application module, EJB module, and Resource adapter module Servlets, JSPs, HTML pages, and Web Deployment Descriptor WAR Substitution variables, authentications, shared libraries, virtual hosts, class loader mode, WAR class loader policy, and start weight. The project interchange format preserves the metadata.
Checkpoint What is an EAR? What are the four types of modules contained in an EAR? What are the three types of archives contained in an EAR? Which archive type contains servlets and JSP pages?
Checkpoint solutions Enterprise Archive EARs can contain the following modules: EJB Web Resource Adapter Client Application The three types of archive files are: WAR (Web Archive) RAR (Resource Archive) JAR (Java Archive) WAR
Japanese Hebrew Thank You English Merci French Russian Danke German Grazie Italian Gracias Spanish Obrigado Portuguese Arabic Simplified Chinese Traditional Chinese Thai Korean

7) packaging and deployment

  • 1.
    Vikas Manoria ITSpecialist – IBM Academic Initiative [email_address] m Section - 7) Packaging and Deployment
  • 2.
    Section 7 - Packaging and Deployment (9%) Create J2EE projects Import and export J2EE modules Create and locate resources in the appropriate location of the project hierarchy Work with Web and Application Deployment Descriptor Editors
  • 3.
    What is J2EE?Enterprise application development Specification Platform for developing, deploying and managing n-tier ,web-enabled ,server centric and component based enterprise application
  • 4.
  • 5.
  • 6.
    J2EE Perspective ProjectExplorer Code Editor Resource Views
  • 7.
    Associating Projects witha Server There are several ways to associate a project with a server: From the project context pop-up menu, select Run As > Run on server You will be able to choose a server in the dialog, and associate the project with that server From the server context pop-up menu in the Servers view, select Add and Remove Projects… The server will be started in order to add or remove projects From the project context pop-up menu, select Properties > Server From here, you can set the runtime target and the default server
  • 8.
    J2EE Packaging TheJ2EE specification defines standard archive formats for all J2EE components EJB module Packaged in a Java archive (.jar) file Web module Packaged in a Web archive (.war) file Application client module Packaged in a Java archive (.jar) file Resource adapter module Packaged in a resource adapter archive (.rar) file Enterprise application Packaged in an enterprise archive (.ear) file
  • 9.
    J2EE Packaging –Containment Hierarchy web resource JSP Servlet client1.jar web1.war res1.rar EJB client class native library adapter jar ejb1.jar app1.ear ejb-jar.xml application-client.xml web.xml web resource JSP Servlet ejb1.jar client1.jar web1.war res1.rar ra.xml EJB client class native library adapter jar application.xml
  • 10.
    EJB Module AnEJB module is contained in an EJB jar file Several beans may be packaged within a single EJB jar file The EJB JAR contains all the classes required for each EJB The enterprise bean class The enterprise bean home and component interfaces The primary key class if the bean is an entity bean The deployment descriptor (ejb-jar.xml) contains: EJB structural information Defining the class names, external dependencies, persistent fields and relationships (for CMP beans) Application assembly information describing how the EJBs fit into a wider application Security information and transaction attribute
  • 11.
    Web Module Webmodules (also known as Web applications) are contained in a Web archive (.WAR) file A WAR file will normally contain several Servlets, JavaServer Pages and other Web resources For example, a Web application may contain HTML files, graphics files, audio files and movies The deployment descriptor (web.xml) contains configuration information for resources contained in the war file For example, initialization parameters, session management configuration, Servlet declarations and mappings, filter definitions, welcome file list, and error pages Security information, tag libraries, and JNDI configuration may also be provided
  • 12.
    Application Client ModuleApplication clients are contained in jar file An application client JAR file contains all the classes required for the client to function The deployment descriptor (application-client.xml) contains configuration information for the client The enterprise beans and external resources referenced by the application client The mechanism for deployment and installation of the application client is not specified in the J2EE specification J2EE product providers may provide an application launcher that integrates with the application client machine’s native operating system
  • 13.
    Resource Adapter ModuleResource adapters are contained in a resource adapter archive (.RAR) file A resource adapter archive RAR file contains: Java code for the resource adapter Utility Java classes for the resource adapter Platform-dependent native libraries required by the resource adapter Help files and documentation The deployment descriptor (ra.xml) contains: General information on the adapter The class names of the connection factory and implementation class Transaction and security information
  • 14.
    Enterprise Application Enterpriseapplications are contained in an enterprise archive (.ear) file An enterprise archive file contains one or more J2EE modules EJB jars, wars, application client jars and rars The enterprise application deployment descriptor (application.xml) contains: Details of all the modules packages in the ear file Definitions of security roles for the enterprise application
  • 15.
    Relationship between Projectsand J2EE Packages In J2EE V1.4 there are four application component types supported by the runtime environment: Application Clients Applets Web applications (servlets, JSPs, and HTML pages) EJBs J2EE components are packaged for deployment as modules: Application client module Web application module EJB module Resource adapter module Rational Application Developer projects map to J2EE packages
  • 16.
    J2EE Packaging StructureReview Web DD EJB Module JAR file Web Module WAR file Client Module JAR file J2EE Application EAR file Installed RARs IBM Bind Schema Map Schema Attributes Table Creation was.policy (Java2 Sec) IBM Bind/Ext HTML, GIFs, and so on Servlet JSP Application DD Client Classes EJBs IBM Bind/Ext IBM Bind/Ext EJB DD Client DD RA DD
  • 17.
    Data Sources Definedin Enhanced EAR Application-related properties and data sources can be defined within an application to simplify application deployment Configuration files added to the J2EE EAR file as an IBM extension Properties are used when application is installed Data source is registered with the WebSphere V6.1 server when the application is started Configuration variables can be defined for substitution with server values when application is installed Enhanced EAR Properties J2EE Enterprise Application (EAR) Components Components Resources
  • 18.
    Other Properties Definedin the Enhanced EAR 1 2 3 4 5 6 7
  • 19.
    Exporting Web ApplicationsA Web application can be exported in two ways using the context menu: As an EAR file As a WAR file
  • 20.
    Sharing Projects betweenWorkspaces Project Interchange is an export feature that allows the export of entire projects. The project structure is maintained, including metadata files. Unlike exporting a WAR, where you may lose metadata. Unrelated projects can be exported. You can then easily import the projects into another workspace with a single action.
  • 21.
    Publishing Applications Application Developer supports: WebSphere test environment in the development environment Tomcat test environment in the development environment WebSphere local or remote server outside the development environment Tomcat local server outside the developer environment J2EE Web publishing server Static Web publishing server
  • 22.
    Publishing Applications The server tools provide several publishing methods that you can use when publishing projects and files. Server Status Server Name and Type
  • 23.
    Checkpoint What arethe four application component types supported by the runtime environment? What are the four modules used to package J2EE components? Name two components of the WAR file. You have a static Web project. Which archive can you use to export it: WAR or EAR? What is one of the most common uses of the enhanced EAR? What is the difference between exporting in .zip format and in project interchange format?
  • 24.
    Checkpoint answers Thefour application component types supported by the runtime environment: Application Clients, Applets, Web applications (servlets, JSPs, HTML pages, and so on), and EJBs The four module types used to package J2EE components: Application client module, Web application module, EJB module, and Resource adapter module Servlets, JSPs, HTML pages, and Web Deployment Descriptor WAR Substitution variables, authentications, shared libraries, virtual hosts, class loader mode, WAR class loader policy, and start weight. The project interchange format preserves the metadata.
  • 25.
    Checkpoint What isan EAR? What are the four types of modules contained in an EAR? What are the three types of archives contained in an EAR? Which archive type contains servlets and JSP pages?
  • 26.
    Checkpoint solutions EnterpriseArchive EARs can contain the following modules: EJB Web Resource Adapter Client Application The three types of archive files are: WAR (Web Archive) RAR (Resource Archive) JAR (Java Archive) WAR
  • 27.
    Japanese Hebrew ThankYou English Merci French Russian Danke German Grazie Italian Gracias Spanish Obrigado Portuguese Arabic Simplified Chinese Traditional Chinese Thai Korean