Java EE Enterprise Archive (EAR) - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Java EE Enterprise Archive (EAR)

Description:

Arranged in a parent/child relationship. Requests for a class are first ... consistent with build environment of free versions of IDEs (Forte, JBuilder, etc. ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 28
Provided by: webdev5
Category:
Tags: ear | archive | enterprise | ides | java

less

Transcript and Presenter's Notes

Title: Java EE Enterprise Archive (EAR)


1
Java EE Enterprise Archive (EAR)
2
Goals
  • Understand the purpose for an EAR
  • Be able to construct an EAR for developed Java EE
    components

3
Objectives
  • EAR Purpose
  • EAR Format

4
Class Loaders
  • Arranged in a parent/child relationship
  • Requests for a class are first delegated to the
    parent class loader
  • May access classes/resources loaded by local and
    parent class loader
  • Do not have access to classes/resources loaded by
    sibling class loaders

5
Separate EJB/WAR Deployment
  • Classes loaded by EJB Application Class Loader
    not seen by Web Application
  • Shared implementations must be placed in both
    applications
  • WEB-INF/lib
  • causes difficulty when passing object between
    applications that have loaded the same class

6
J2EE Enterprise Application Deployment
Application Server Class Loader
EAR Class Loader
EJB interfaces and dependent classes identified
by EJB manifests loaded by EARs classloader
EAR Class Loader
  • All EJBs are loaded by a single class loader
  • may also include web dependent classes identified
    through manifest entries to promote singleton
    loading of classes across web applications

EJB App Class Loader
Web App 2 Class Loader
Web App 1 Class Loader
Servlets/JSPs and lib.jars loaded by isolated
classloaders
7
Enterprise Application Archive (EAR)
  • WAR(s)
  • directory or archive
  • EJB(s)
  • directory or archive
  • Client JAR(s)
  • client applications
  • Utility Classes(s)
  • directory or archive
  • supplies external source utility classes
  • referenced through MANIFESTs
  • Resource Adapters(s)
  • custom resource drivers

8
Directory and Archive Forms
  • Exploded Directory Form
  • ability to modify static files (html/jsp) without
    redeploying
  • separate server serves up content in exploded
    form
  • simpler build environment
  • consistent with build environment of free
    versions of IDEs (Forte, JBuilder, etc.)
  • Archive File Format
  • easy form of distribution

9
application.xml
application
icon
display-name
description?
module
security-role
small-icon
large-icon
description?
ejbconnectorjavaweb
alt-dd
role-name
web-uri
context-root
10
Element Definitions
  • Application
  • Declares the overall enterprise application
  • Deployment Tool Info
  • icon, display-name, description
  • Modules
  • ejb EJBs (Ex. EJB1.jar)
  • web web applications
  • java - client applications
  • connector JCA resource adapters

11
Element Definitions (Cont)
  • Web applications
  • web-uri (ex. webapp1.war)
  • context-root
  • Name of web apps context
  • May be empty if only one webapp in the
    application
  • alt-dd
  • Can override the deployment descriptor found in
    the module
  • security-role
  • Define application-level security roles

12
application.xml Example
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • lt!DOCTYPE application PUBLIC
  • "-//Sun Microsystems, Inc.//DTD J2EE
    Application 1.3//EN"
  • "http//java.sun.com/dtd/application_1_3.d
    td"gt
  • ltapplicationgt
  • ltdisplay-namegtejbsessionBankEARlt/display-namegt
  • ltdescriptiongtExample Session Bean Bank
    Applicationlt/descriptiongt
  • ltmodulegt
  • ltwebgt
  • ltweb-urigtejbsessionBankWAR.warlt/web-urigt
  • ltcontext-rootgt/ejbsessionBankWARlt/context-ro
    otgt
  • lt/webgt
  • lt/modulegt
  • ltmodulegt
  • ltejbgtejbsessionBankEJB-1.0.2007.2-SNAPSHOT.jar
    lt/ejbgt
  • lt/modulegt

13
Example Project with EAR
  • ejbsessionBankgt jar tf ejbsessionBankEAR/target/ej
    bsessionBankEAR-1.0.2007.2-SNAPSHOT.ear
  • META-INF/
  • META-INF/MANIFEST.MF
  • ejbsessionBankImpl-1.0.2007.2-SNAPSHOT.jar
  • ejbsessionBankWAR.war
  • ejbsessionBankEJB-1.0.2007.2-SNAPSHOT.jar
  • META-INF/application.xml
  • EJB META-INF/MANIFEST.MF
  • Manifest-Version 1.0
  • Archiver-Version Plexus Archiver
  • Created-By Apache Maven
  • Built-By StaffordJ
  • Build-Jdk 1.5.0_17
  • Class-Path commons-logging-1.0.4.jar
    ejbsessionBankImpl-1.0.2007.2-SNAPSHOT.jar

14
Example Project with EAR source tree
  • ejbsessionBankgt tree .
  • -- ejbsessionBankImpl
  • ...
  • -- ejbsessionBankEAR
  • -- pom.xml
  • -- ejbsessionBankEJB
  • ...
  • -- ejbsessionBankTest
  • ...
  • -- ejbsessionBankWAR
  • ...
  • -- pom.xml

15
Example Project with EAR root pom.xml
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • ltproject xmlns"http//maven.apache.org/POM/4.0.0"
    xmlnsxsi"http//www.w3.org/2001/XMLSchema-insta
    nce" xsischemaLocation"http//maven.apache.org/P
    OM/4.0.0 http//maven.apache.org/maven-v4_0_0.xsd"
    gt
  • ltmodelVersiongt4.0.0lt/modelVersiongt
  • ltgroupIdgtejava.javaee.ejblt/groupIdgt
  • ltartifactIdgtejbsessionBanklt/artifactIdgt
  • ltpackaginggtpomlt/packaginggt
  • ltnamegtSession Beanlt/namegt
  • ltversiongt1.0-SNAPSHOTlt/versiongt
  • ltdescriptiongt
  • This project is the root project for the
    core session bean example.
  • lt/descriptiongt
  • ltmodulesgt
  • ltmodulegtejbsessionBankImpllt/modulegt
  • ltmodulegtejbsessionBankEJBlt/modulegt
  • ltmodulegtejbsessionBankWARlt/modulegt
  • ltmodulegtejbsessionBankEARlt/modulegt
  • ltmodulegtejbsessionBankTestlt/modulegt
  • lt/modulesgt
  • lt/projectgt

16
Example Project with EAR ear pom.xml
  • ltmodelVersiongt4.0.0lt/modelVersiongt
  • ltgroupIdgtejava.javaee.ejblt/groupIdgt
  • ltartifactIdgtejbsessionBankEARlt/artifactIdgt
  • ltpackaginggtearlt/packaginggt
  • ltnamegtSession Bank EARlt/namegt
  • ltversiongt1.0-SNAPSHOTlt/versiongt
  • ltdependenciesgt
  • ltdependencygt
  • ltgroupIdgtpom.groupIdlt/groupIdgt
  • ltartifactIdgtejbsessionBankEJBlt/artifac
    tIdgt
  • ltversiongtpom.versionlt/versiongt
  • lttypegtejblt/typegt
  • lt/dependencygt
  • ltdependencygt
  • ltgroupIdgtpom.groupIdlt/groupIdgt
  • ltartifactIdgtejbsessionBankWARlt/artifac
    tIdgt
  • ltversiongtpom.versionlt/versiongt
  • lttypegtwarlt/typegt
  • lt/dependencygt

17
Example Project with EAR excluding unwanted
dependencies
  • ltdependencygt
  • ltgroupIdgtpom.groupIdlt/groupIdgt
  • ltartifactIdgtejbsessionBankEJBlt/artifac
    tIdgt
  • ltversiongtpom.versionlt/versiongt
  • lttypegtejblt/typegt
  • ltexclusionsgt
  • ltexclusiongt
  • ltgroupIdgtcommons-logginglt/grou
    pIdgt
  • ltartifactIdgtcommons-logginglt/a
    rtifactIdgt
  • lt/exclusiongt
  • lt/exclusionsgt
  • lt/dependencygt

18
Example Project with EAR ear plugin
  • ltbuildgt
  • ltpluginsgt
  • ltplugingt
  • ltgroupIdgtorg.apache.maven.pluginslt
    /groupIdgt
  • ltartifactIdgtmaven-ear-pluginlt/arti
    factIdgt
  • ltconfigurationgt
  • ltdescriptiongt
  • Example Session Bean Bank
    Application
  • lt/descriptiongt
  • ltmodulesgt
  • ltwebModulegt
  • ltgroupIdgtpom.groupIdlt/g
    roupIdgt
  • ltartifactIdgtejbsessionBank
    WARlt/artifactIdgt
  • ltcontextRootgtejbsessionban
    klt/contextRootgt
  • lt/webModulegt
  • lt/modulesgt
  • lt/configurationgt
  • lt/plugingt
  • lt/pluginsgt

19
Example EAR Project build output
  • gt tree.
  • -- pom.xml
  • -- target
  • -- application.xml
  • -- ejbsessionBankEAR-1.0.2007.2-SNAPSHOT
  • -- META-INF
  • -- application.xml
  • -- ejbsessionBankImpl-1.0.2007.2-SNAPSHOT
    .jar
  • -- ejbsessionBankEJB-1.0.2007.2-SNAPSHOT.
    jar
  • -- ejbsessionBankWAR-1.0.2007.2-SNAPSHOT.
    war
  • -- ejbsessionBankEAR-1.0.2007.2-SNAPSHOT.ear

20
Example EAR Project deploying EAR with cargo
(Test/pom.xml)
  • ltplugingt
  • ltgroupIdgtorg.codehaus.cargolt/groupIdgt
  • ltartifactIdgtcargo-maven2-pluginlt/artifactIdgt
  • ltconfigurationgt
  • ltcontainergt
  • ltcontainerIdgtjboss4xlt/containerIdgt
  • lttypegtremotelt/typegt
  • lt/containergt
  • lt/configurationgt
  • ltexecutionsgt
  • ltexecutiongt
  • ...
  • lt/executiongt
  • lt/executionsgt
  • lt/plugingt

21
Example EAR Project deploying EAR with cargo
(Test/pom.xml)
  • ltexecutiongt
  • ltidgtdeploy-componentlt/idgt
  • lt!-- jump into a phase before
    surefire runs tests --gt
  • ltphasegttest-compilelt/phasegt
  • ltgoalsgt
  • ltgoalgtundeploylt/goalgt
  • ltgoalgtdeploylt/goalgt
  • lt/goalsgt
  • ltconfigurationgt
  • ltconfigurationgt
  • lttypegtruntimelt/typegt
  • ltpropertiesgt
  • ltcargo.remote.usernamegt
    jboss.userlt/cargo.remote.usernamegt
  • ltcargo.remote.passwordgt
    jboss.passwordlt/cargo.remote.passwordgt
  • lt/propertiesgt
  • lt/configurationgt
  • ...

22
Example EAR Project deploying EAR with cargo
(Test/pom.xml)
  • ...
  • ltdeployergt
  • lttypegtremotelt/typegt
  • ltdeployablesgt
  • ltdeployablegt
  • ltgroupIdgtpom.groupId
    lt/groupIdgt
  • ltartifactIdgtejbsession
    BankEARlt/artifactIdgt
  • lttypegtearlt/typegt
  • lt/deployablegt
  • lt/deployablesgt
  • lt/deployergt
  • lt/configurationgt
  • lt/executiongt

23
Example EAR Project deploying EAR with cargo
(Test project output)
  • Test output
  • INFO Building Session Bank Test
  • INFO task-segment install
  • INFO -------------------------------------------
    ---------------------------------
  • ...
  • INFO cargoundeploy execution
    deploy-component
  • INFO cargodeploy execution
    deploy-component
  • Server Console
  • 233850,173 INFO EARDeployer Undeploying J2EE
    application, destroy step file/home/jcstaff/proj
    /ejava-javaee/working/ejbsessionBank/ejbsessionBan
    kEAR/target/ejbsessionBankEAR-1.0.2007.2-SNAPSHOT.
    ear
  • 233850,174 INFO EARDeployer Undeployed J2EE
    application file/home/jcstaff/proj/ejava-javaee/
    working/ejbsessionBank/ejbsessionBankEAR/target/ej
    bsessionBankEAR-1.0.2007.2-SNAPSHOT.ear
  • 233850,272 INFO EARDeployer Init J2EE
    application file/home/jcstaff/proj/ejava-javaee/
    working/ejbsessionBank/ejbsessionBankEAR/target/ej
    bsessionBankEAR-1.0.2007.2-SNAPSHOT.ear

24
Example EAR Project undeploying EAR with cargo
(EAR/pom.xml)
  • ltplugingt
  • ltgroupIdgtorg.codehaus.cargolt/groupIdgt
  • ltartifactIdgtcargo-maven2-pluginlt/artifactIdgt
  • ltconfigurationgt
  • ltcontainergt
  • ltcontainerIdgtjboss4xlt/containerIdgt
  • lttypegtremotelt/typegt
  • lt/containergt
  • lt/configurationgt
  • ltexecutionsgt
  • ltexecutiongt
  • ltidgtundeploy-earlt/idgt
  • ltphasegtpre-cleanlt/phasegt
  • ltgoalsgt
  • ltgoalgtundeploylt/goalgt
  • lt/goalsgt
  • ltconfigurationgt
  • ltconfigurationgt
  • lttypegtruntimelt/typegt

25
Example EAR Project undeploying EAR with cargo
(EAR/pom.xml)
  • ...
  • ltpropertiesgt
  • ltcargo.remote.usernamegtjboss
    .userlt/cargo.remote.usernamegt
  • ltcargo.remote.passwordgtjboss
    .passwordlt/cargo.remote.passwordgt
  • lt/propertiesgt
  • lt/configurationgt
  • ltdeployergt
  • lttypegtremotelt/typegt
  • ltdeployablesgt
  • ltdeployablegt
  • ltgroupIdgtpom.groupId
    lt/groupIdgt
  • ltartifactIdgtpom.arti
    factIdlt/artifactIdgt
  • lttypegtearlt/typegt
  • lt/deployablegt
  • lt/deployablesgt
  • lt/deployergt
  • lt/configurationgt
  • lt/executiongt
  • lt/executionsgt

26
Example EAR Project undeploying EAR with cargo
(EAR project output)
  • Build output
  • gt mvn clean -Pundeploy
  • ...
  • INFO Building Session Bank EAR
  • INFO task-segment clean
  • INFO -------------------------------------------
    ---------------------------------
  • INFO cargoundeploy execution undeploy-ear
  • INFO cleanclean
  • ...
  • Server console
  • 234858,499 INFO EARDeployer Undeploying J2EE
    application, destroy step file/home/jcstaff/proj
    /ejava-javaee/working/ejbsessionBank/ejbsessionBan
    kEAR/target/ejbsessionBankEAR-1.0.2007.2-SNAPSHOT.
    ear
  • 234858,500 INFO EARDeployer Undeployed J2EE
    application file/home/jcstaff/proj/ejava-javaee/
    working/ejbsessionBank/ejbsessionBankEAR/target/ej
    bsessionBankEAR-1.0.2007.2-SNAPSHOT.ear

27
Summary
  • EARs provide a standard deployment package to the
    application server
  • Application server class loader(s) are designed
    to provide efficient sharing of resources defined
    within the EAR
  • EAR is a deployment package, cannot be unit
    tested
  • requires deployment
  • requires functional testing that incorporates
    application server
Write a Comment
User Comments (0)
About PowerShow.com