Download presentation
Presentation is loading. Please wait.
Published byVictoria Ada Tucker Modified over 9 years ago
1
Enterprise Java v090401JavaEE EAR1 Java EE Enterprise Archive (EAR)
2
Enterprise Java v090401JavaEE EAR2 Goals Understand the purpose for an EAR Be able to construct an EAR for developed Java EE components
3
Enterprise Java v090401JavaEE EAR3 Objectives EAR Purpose EAR Format
4
Enterprise Java v090401JavaEE EAR4 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 Parent Class Loader Child Class Loader
5
Enterprise Java v090401JavaEE EAR5 Application Server Class Loader EJB App Class Loader Web App Class Loader Web App Class Loader 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
Enterprise Java v090401JavaEE EAR6 J2EE Enterprise Application Deployment Application Server Class Loader EAR Class Loader EJB App Class Loader EAR Class Loader Web App 2 Class Loader Web App 1 Class Loader Servlets/JSPs and lib.jars loaded by isolated classloaders 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 interfaces and dependent classes identified by EJB manifests loaded by EAR’s classloader
7
Enterprise Java v090401JavaEE EAR7 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 WAR EJB EAR META-INF/application.xml Utility Classes Resource Adapter Resource Adapter Resource Adapter Client App Client App Client App Utility Classes Utility Classes
8
Enterprise Java v090401JavaEE EAR8 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
Enterprise Java v090401JavaEE EAR9 application icon small-iconlarge-icon display-namedescription?module+security-role* ejb|connector|java|webalt-dd web-uricontext-root description? role-name application.xml
10
Enterprise Java v090401JavaEE EAR10 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
Enterprise Java v090401JavaEE EAR11 Element Definitions (Cont) Web applications –web-uri (ex. webapp1.war) –context-root Name of web app’s 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
Enterprise Java v090401JavaEE EAR12 application.xml Example <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd"> ejbsessionBankEAR Example Session Bean Bank Application ejbsessionBankWAR.war /ejbsessionBankWAR ejbsessionBankEJB-1.0.2007.2-SNAPSHOT.jar
13
Enterprise Java v090401JavaEE EAR13 Example Project with EAR ejbsessionBank> jar tf ejbsessionBankEAR/target/ejbsessionBankEAR-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
Enterprise Java v090401JavaEE EAR14 Example Project with EAR: source tree ejbsessionBank> tree. |-- ejbsessionBankImpl... |-- ejbsessionBankEAR | |-- pom.xml |-- ejbsessionBankEJB... |-- ejbsessionBankTest... |-- ejbsessionBankWAR... |-- pom.xml
15
Enterprise Java v090401JavaEE EAR15 Example Project with EAR: root pom.xml 4.0.0 ejava.javaee.ejb ejbsessionBank pom Session Bean 1.0-SNAPSHOT This project is the root project for the core session bean example. ejbsessionBankImpl ejbsessionBankEJB ejbsessionBankWAR ejbsessionBankEAR ejbsessionBankTest
16
Enterprise Java v090401JavaEE EAR16 Example Project with EAR: ear pom.xml 4.0.0 ejava.javaee.ejb ejbsessionBankEAR ear Session Bank EAR 1.0-SNAPSHOT ${pom.groupId} ejbsessionBankEJB ${pom.version} ejb ${pom.groupId} ejbsessionBankWAR ${pom.version} war
17
Enterprise Java v090401JavaEE EAR17 Example Project with EAR: excluding unwanted dependencies ${pom.groupId} ejbsessionBankEJB ${pom.version} ejb commons-logging
18
Enterprise Java v090401JavaEE EAR18 Example Project with EAR: ear plugin org.apache.maven.plugins maven-ear-plugin Example Session Bean Bank Application ${pom.groupId} ejbsessionBankWAR ejbsessionbank
19
Enterprise Java v090401JavaEE EAR19 Example EAR Project: build output > 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
Enterprise Java v090401JavaEE EAR20 Example EAR Project: deploying EAR with cargo (Test/pom.xml) org.codehaus.cargo cargo-maven2-plugin jboss4x remote...
21
Enterprise Java v090401JavaEE EAR21 Example EAR Project: deploying EAR with cargo (Test/pom.xml) deploy-component test-compile undeploy deploy runtime ${jboss.user} ${jboss.password}...
22
Enterprise Java v090401JavaEE EAR22 Example EAR Project: deploying EAR with cargo (Test/pom.xml)... remote ${pom.groupId} ejbsessionBankEAR ear
23
Enterprise Java v090401JavaEE EAR23 Example EAR Project: deploying EAR with cargo (Test project output) Test output [INFO] Building Session Bank Test [INFO] task-segment: [install] [INFO] ----------------------------------------------------------------------------... [INFO] [cargo:undeploy {execution: deploy-component}] [INFO] [cargo:deploy {execution: deploy-component}] Server Console 23:38:50,173 INFO [EARDeployer] Undeploying J2EE application, destroy step: file:/home/jcstaff/proj/ejava- javaee/working/ejbsessionBank/ejbsessionBankEAR/target/ejbsessionBankEAR- 1.0.2007.2-SNAPSHOT.ear 23:38:50,174 INFO [EARDeployer] Undeployed J2EE application: file:/home/jcstaff/proj/ejava- javaee/working/ejbsessionBank/ejbsessionBankEAR/target/ejbsessionBankEAR- 1.0.2007.2-SNAPSHOT.ear 23:38:50,272 INFO [EARDeployer] Init J2EE application: file:/home/jcstaff/proj/ejava- javaee/working/ejbsessionBank/ejbsessionBankEAR/target/ejbsessionBankEAR- 1.0.2007.2-SNAPSHOT.ear
24
Enterprise Java v090401JavaEE EAR24 Example EAR Project: undeploying EAR with cargo (EAR/pom.xml) org.codehaus.cargo cargo-maven2-plugin jboss4x remote undeploy-ear pre-clean undeploy runtime...
25
Enterprise Java v090401JavaEE EAR25 Example EAR Project: undeploying EAR with cargo (EAR/pom.xml)... ${jboss.user} ${jboss.password} remote ${pom.groupId} ${pom.artifactId} ear
26
Enterprise Java v090401JavaEE EAR26 Example EAR Project: undeploying EAR with cargo (EAR project output) Build output > mvn clean -Pundeploy... [INFO] Building Session Bank EAR [INFO] task-segment: [clean] [INFO] ---------------------------------------------------------------------------- [INFO] [cargo:undeploy {execution: undeploy-ear}] [INFO] [clean:clean]... Server console 23:48:58,499 INFO [EARDeployer] Undeploying J2EE application, destroy step: file:/home/jcstaff/proj/ejava- javaee/working/ejbsessionBank/ejbsessionBankEAR/target/ejbsessionBankEAR- 1.0.2007.2-SNAPSHOT.ear 23:48:58,500 INFO [EARDeployer] Undeployed J2EE application: file:/home/jcstaff/proj/ejava- javaee/working/ejbsessionBank/ejbsessionBankEAR/target/ejbsessionBankEAR- 1.0.2007.2-SNAPSHOT.ear
27
Enterprise Java v090401JavaEE EAR27 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.