Title: J2EE Enterprise Application Physical Construction
1J2EE Enterprise ApplicationPhysical Construction
2Objectives
- Enterprise Application ARchive (EAR) Purpose
- EAR Format
- WAR Format
- EJB Format
- Accessing Application Resources
- Client Application Format
- Building an EAR
- Deploying an EAR
- Running an EAR
3Class 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
4Separate 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
5J2EE 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
6Enterprise 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
7Directory 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
8application.xml
application
icon
display-name
description?
module
security-role
small-icon
large-icon
description?
ejbconnectorjavaweb
alt-dd
role-name
web-uri
context-root
9Element 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
10Element 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
11application.xml Example
- lt!DOCTYPE application PUBLIC '-//Sun
Microsystems, Inc.//DTD J2EE Application 1.3//EN'
'http//java.sun.com/dtd/application_1_3.dtd'gt - ltapplicationgt
- ltdisplay-namegtSimple Applt/display-namegt
- ltmodulegt
- ltejbgthelloWorldEJBlt/ejbgt
- lt/modulegt
- ltmodulegt
- ltwebgt
- ltweb-urigtsimpleWEBlt/web-urigt
- ltcontext-rootgtsimpleApplt/context-rootgt
- lt/webgt
- lt/modulegt
- lt/applicationgt
12WAR Format
- WEB-INF/
- directory to place private files
- WEB-INF/web.xml
- a J2EE standard file that registers web resources
to the container - WEB-INF/weblogic.xml
- maps web.xml resource references to resources in
the application server - defines container-specific options (ex. enable
URL re-writing) - WEB-INF/classes
- web application servlet classes are placed below
this directory - WEB-INF/lib/
- /
- location to place normal Web Resources
13WAR Example
- WEB-INF/
- WEB-INF/classes/
- WEB-INF/classes/helloname/
- WEB-INF/classes/helloname/web/
- WEB-INF/classes/helloname/web/HelloNameServlet.cla
ss - WEB-INF/classes/helloweb/
- WEB-INF/classes/helloweb/HelloWebServlet.class
- WEB-INF/classes/helloworld/
- WEB-INF/classes/helloworld/web/
- WEB-INF/classes/helloworld/web/HelloWorldServlet.c
lass - WEB-INF/web.xml
- WEB-INF/weblogic.xml
- displayMessage.jsp
- index.jsp
14web.xml Example
- lt!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
Inc.//DTD Web Application 2.3//EN"
"http//java.sun.com/dtd/web-app_2_3.dtd"gt - ltweb-appgt
- ltservletgt
- ltservlet-namegtHelloWorldlt/servlet-namegt
- ltservlet-classgthelloworld.web.HelloWorldServle
tlt/servlet-classgt - lt/servletgt
- ltservlet-mappinggt
- ltservlet-namegtHelloWorldlt/servlet-namegt
- lturl-patterngt/helloworldlt/url-patterngt
- lt/servlet-mappinggt
Names the Servlet Class within the Deployment
Maps Servlet to a name within the application
15web.xml Example
- ltenv-entrygt
- ltenv-entry-namegtdisplayURIlt/env-entry-namegt
- ltenv-entry-valuegt/displayMessage.jsplt/env-entr
y-valuegt - ltenv-entry-typegtjava.lang.Stringlt/env-entry-ty
pegt - lt/env-entrygt
- ltejb-refgt
- ltejb-ref-namegtejb/HelloWorldRemoteHomelt/ejb-re
f-namegt - ltejb-ref-typegtSessionlt/ejb-ref-typegt
- lthomegtspeaker.HelloWorldRemoteHomelt/homegt
- ltremotegtspeaker.HelloWorldRemotelt/remotegt
- ltejb-linkgtHelloWorldEJBlt/ejb-linkgt
- lt/ejb-refgt
- lt/web-appgt
Places values in JNDI tree. Located with lookup
of javacomp/env/displayURI
Maps a hard-coded name in the java code to a
resource type to be resolved to within the
application server. Located with lookup
of javacomp/env/ ejb/HelloWorldRemoteHome
16weblogic.xml Example
- lt!DOCTYPE weblogic-web-app PUBLIC "-//BEA
Systems, Inc.//DTD Web Application 6.1//EN"
"http//www.bea.com/servers/wls610/dtd/weblogic-we
b-jar.dtd"gt - ltweblogic-web-appgt
- ltreference-descriptorgt
- ltejb-reference-descriptiongt
- ltejb-ref-namegtejb/HelloWorldRemoteHomelt/e
jb-ref-namegt - ltjndi-namegtsimpleApp/HelloWorldRemoteHome
- lt/jndi-namegt
- lt/ejb-reference-descriptiongt
- lt/reference-descriptorgt
- lt/weblogic-web-appgt
Maps resource reference from web.xml to object
in global JNDI tree
Note In WLS 7.0, the specification of
ejb-link in the ejb-jar.xml makes the
ejb-reference-description unnecessary.
17javacomp/env
- Goal Allow J2EE components to refer to resources
using logical names - Map to deployed names via a deployment descriptor
- Logical namespace begins with javacomp/env
HelloWorld Home Object
simpleApp
ejb/HelloWorldRemoteHome
lookup
Mapped to
HelloWorld RemoteHome
servlet
Deployed to
18Web Component using javacomp/env
HelloRemote hello null try
Context jndi new InitialContext()
Object object jndi.lookup(javacomp/env/
ejb/HelloWorldRemoteHome)
HelloWorldRemoteHome rHome (HelloWorldRemoteHome
) PortableRemoteObject.narrow(obj
ect, HelloWorldRemoteHome.class)
19EJB Format
- META-INF/
- META-INF/MANIFEST.MF
- META-INF/ejb-jar.xml
- META-INF/weblogic-ejb-jar.xml
- helloworld/
- helloworld/HelloWorldEJB.class
- helloworld/HelloWorldRemote.class
- helloworld/HelloWorldRemoteHome.class
- helloworld/HelloWorldEJB_ldzvb1_EOImpl.class
- helloworld/HelloWorldEJB_ldzvb1_EOImplRTD.xml
- helloworld/HelloWorldEJB_ldzvb1_HomeImpl.class
- helloworld/HelloWorldEJB_ldzvb1_HomeImplRTD.xml
- helloworld/HelloWorldEJB_ldzvb1_Impl.class
Created by container
20ejb-jar.xml Example
- lt!DOCTYPE ejb-jar PUBLIC
- '-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN' 'http//java.sun.com/dtd/ejb-ja
r_2_0.dtd'gt - ltejb-jargt
- ltenterprise-beansgt
- ...
- lt/enterprise-beansgt
- lt/ejb-jargt
21ejb-jar.xml Example Stateless Session
Bean/Remote Ifaces
- ltsessiongt
- ltejb-namegtHelloEJBlt/ejb-namegt
- lthomegthello.HelloRemoteHomelt/homegt
- ltremotegthello.HelloRemotelt/remotegt
- ltejb-classgthello.HelloEJBlt/ejb-classgt
- ltsession-typegtStatelesslt/session-typegt
- lttransaction-typegtContainerlt/transaction-typegt
- ltejb-local-refgt
- ltejb-ref-namegtejb/MessageLocalHomelt/ejb-ref-na
megt - ltejb-ref-typegtEntitylt/ejb-ref-typegt
- ltlocal-homegthello.MessageLocalHomelt/local-home
gt - ltlocalgthello.MessageLocallt/localgt
- ltejb-linkgtMessageEJBlt/ejb-linkgt
- lt/ejb-local-refgt
- lt/sessiongt
22ejb-jar.xml Example Entity Bean/Local Ifaces
- ltentitygt
- ltejb-namegtMessageEJBlt/ejb-namegt
- ltlocal-homegthello.MessageLocalHomelt/local-homegt
- ltlocalgthello.MessageLocallt/localgt
- ltejb-classgthello.MessageEJBlt/ejb-classgt
- ltpersistence-typegtContainerlt/persistence-typegt
- ltprim-key-classgtjava.lang.Integerlt/prim-key-clas
sgt - ltreentrantgtFalselt/reentrantgt
- ltcmp-fieldgt
- ltfield-namegtidlt/field-namegt
- lt/cmp-fieldgt
- ltcmp-fieldgt
- ltfield-namegtmessagelt/field-namegt
- lt/cmp-fieldgt
- ltprimkey-fieldgtidlt/primkey-fieldgt
- lt/entitygt
23weblogic-ejb-jar.xmlExample Session Bean
- lt!DOCTYPE weblogic-ejb-jar PUBLIC
- '-//BEA Systems, Inc.//DTD WebLogic 6.0.0
EJB//EN' 'http//www.bea.com/servers/wls600/dtd/we
blogic-ejb-jar.dtd'gt - ltweblogic-ejb-jargt
- ltweblogic-enterprise-beangt
- ltejb-namegtHelloEJBlt/ejb-namegt
- ltjndi-namegtejava/examples/simpleApp/HelloRemot
eHomelt/jndi-namegt - lt/weblogic-enterprise-beangt
- ...
- lt/weblogic-ejb-jargt
24weblogic-ejb-jar.xmlExample Entity Bean
- ltweblogic-enterprise-beangt
- ltejb-namegtMessageEJBlt/ejb-namegt
- ltentity-descriptorgt
- ltpersistencegt
- ltpersistence-typegt
- lttype-identifiergtWebLogic_CMP_RDBMSlt/typ
e-identifiergt - lttype-versiongt6.0lt/type-versiongt
- lttype-storagegtMETA-INF/weblogic-cmp-rdbm
s-jar.xmllt/type-storagegt - lt/persistence-typegt
- ltpersistence-usegt
- lttype-identifiergtWebLogic_CMP_RDBMSlt/typ
e-identifiergt - lttype-versiongt6.0lt/type-versiongt
- lt/persistence-usegt
- lt/persistencegt
- lt/entity-descriptorgt
- ltlocal-jndi-namegtejava/examples/simpleApp/Mess
ageLocalHome - lt/local-jndi-namegt
- lt/weblogic-enterprise-beangt
- lt/weblogic-ejb-jargt
25jboss.xmlExample Session Entity Beans
ltjbossgt ltenterprise-beansgt ltsessiongt
ltejb-namegtHelloEJBlt/ejb-namegt
ltjndi-namegtcorej2ee/examples/simpleApp/HelloRemote
Homelt/jndi-namegt lt/sessiongt ltentitygt
ltejb-namegtMessageEJBlt/ejb-namegt
ltjndi-namegtcorej2ee/examples/simpleApp/MessageLoca
lHomelt/jndi-namegt lt/entitygt
lt/enterprise-beansgt lt/jbossgt
26weblogic-cmp-rdbms.xmlExample Entity Beans
ltweblogic-rdbms-jargt ltweblogic-rdbms-beangt
ltejb-namegtMessageEJBlt/ejb-namegt
ltdata-source-namegtcoredev.jdbc.DSlt/data-source-nam
egt lttable-mapgt
lttable-namegtsimpleApp_Messagelt/table-namegt
ltfield-mapgt
ltcmp-fieldgtidlt/cmp-fieldgt
ltdbms-columngtidlt/dbms-columngt
lt/field-mapgt ltfield-mapgt
ltcmp-fieldgtmessagelt/cmp-fieldgt
ltdbms-columngtmessagelt/dbms-columngt
lt/field-mapgt lt/table-mapgt
lt/weblogic-rdbms-beangt ltcreate-default-dbms-t
ablesgtDropAndCreatelt/create-default-dbms-tablesgt lt
/weblogic-rdbms-jargt
27jbosscmp.xmlExample Entity Beans
ltjbosscmp-jdbcgt ltdefaultsgt
ltdatasourcegtjavacoredev.jdbc.DSlt/datasourcegt
ltdatasource-mappinggtHypersonic
SQLlt/datasource-mappinggt ltcreate-tablegttruelt
/create-tablegt ltremove-tablegttruelt/remove-ta
blegt lt/defaultsgt ltenterprise-beansgt
ltentitygt ltejb-namegtMessageEJBlt/ejb-namegt
lttable-namegtsimpleApp_Messagelt/table-name
gt ltcmp-fieldgt
ltfield-namegtidlt/field-namegt
ltcolumn-namegtidlt/column-namegt
lt/cmp-fieldgt ltcmp-fieldgt
ltfield-namegtmessagelt/field-namegt
ltcolumn-namegtmessagelt/column-namegt
lt/cmp-fieldgt lt/entitygt
lt/enterprise-beansgt lt/jbosscmp-jdbcgt
28EJB -gt JAR Dependencies
- helloNameEJB.jar
- META-INF/MANIFEST.MF
- helloname/HelloNameEJB.class
- helloname/HelloNameRemote.class
- helloname/HelloNameRemoteHome.class
- helloUtil.jar
- util/Name.class
- HelloNameEJB.java
- package helloname
- import util.Name
- public class HelloNameEJB implements SessionBean
- public String speak(Name name)
- return "hello " name
-
29MANIFEST.MF Example
- helloNameEJB/META-INF/MANIFEST.MF
- Manifest-Version 1.0
- Class-Path . helloUtil.jar
- . - used by container when deployed in exploded
tree format to locate util/Name.class inside . - helloUtil.jar - used by container when deployed
in archive format to locate util/Name.class
inside helloUtil.jar
30Accessing Resources
InputStream is Thread.currentThread().
getContextClassLoader().
getResourceAsStream("util/hello.properties")
System ClassLoader
EJB ClassLoader
helloUtil.jar util/Name.class util/hello.propertie
s
helloName.jar META-INF/MANIFEST.MF helloname.Hello
NameEJB.class
MANIFEST.MF Class-Path helloUtil.jar
hello.properties web.messageHave a nice
Day! ejb.messageHow you doing!
simpleWEB ClassLoader
simpleWEB.war WEB-INF/classes/helloname.web.HelloN
ameServlet.class
31Inspecting the ClassLoaders (WLS)
- public static void dumpLoader(String name,
ClassLoader loader) - System.out.println("
") - System.out.println(name " loader"
loader) - loader loader.getParent()
- while (loader ! null)
- System.out.println("- loader" loader)
- loader loader.getParent()
-
- System.out.println("
") -
- dumpLoader("HelloNameServlet", HelloNameServlet.cl
ass.getClassLoader()) -
- HelloNameServlet loaderweblogic.utils.classloader
s.ChangeAwareClassLoader_at_e994b - finder weblogic.utils.classloaders.MultiClassFin
der_at_60eda5 - - loaderweblogic.utils.classloaders.GenericClassL
oader_at_75a6f9 finder weblogic. - utils.classloaders.MultiClassFinder_at_12172b
- - loadersun.misc.LauncherAppClassLoader_at_71732b
- - loadersun.misc.LauncherExtClassLoader_at_7fdcde
-
32Inspecting the ClassLoaders (WLS)
- dumpLoader("HelloNameEJB", HelloNameEJB.class.getC
lassLoader()) -
- HelloNameEJB loaderweblogic.utils.classloaders.Ge
nericClassLoader_at_75a6f9 finder - weblogic.utils.classloaders.MultiClassFinder_at_121
72b - - loadersun.misc.LauncherAppClassLoader_at_71732b
- - loadersun.misc.LauncherExtClassLoader_at_7fdcde
-
- dumpLoader("Name", Name.class.getClassLoader())
-
- Name loaderweblogic.utils.classloaders.GenericCla
ssLoader_at_75a6f9 finder weblog - ic.utils.classloaders.MultiClassFinder_at_12172b
- - loadersun.misc.LauncherAppClassLoader_at_71732b
- - loadersun.misc.LauncherExtClassLoader_at_7fdcde
-
- dumpLoader("system", ClassLoader.getSystemClassLoa
der()) -
- system loadersun.misc.LauncherAppClassLoader_at_717
32b - - loadersun.misc.LauncherExtClassLoader_at_7fdcde
33Inspecting the ClassLoaders (JBoss)
- dumpLoader("HelloNameServlet", HelloNameServlet.cl
ass.getClassLoader()) -
- 'HelloNameServlet' loaderorg.jboss.mx.loading.Uni
fiedClassLoader3_at_15023d2 urlfile/C/app - - loaderorg.jboss.system.server.NoAnnotationURLCl
assLoader_at_f62373 - - loadersun.misc.LauncherAppClassLoader_at_12f6684
- - loadersun.misc.LauncherExtClassLoader_at_f38798
34Inspecting the ClassLoaders (JBoss)
- dumpLoader("HelloNameEJB", HelloNameEJB.class.getC
lassLoader()) -
- 'HelloNameEJB' loaderorg.jboss.mx.loading.Unified
ClassLoader3_at_15023d2 urlfile/C/apps/jb - - loaderorg.jboss.system.server.NoAnnotationURLCl
assLoader_at_f62373 - - loadersun.misc.LauncherAppClassLoader_at_12f6684
- - loadersun.misc.LauncherExtClassLoader_at_f38798
- dumpLoader("Na
me", Name.class.getClassLoader()) -
- 'Name' loaderorg.jboss.mx.loading.UnifiedClassLoa
der3_at_15023d2 urlfile/C/apps/jboss-4.0. - - loaderorg.jboss.system.server.NoAnnotationURLCl
assLoader_at_f62373 - - loadersun.misc.LauncherAppClassLoader_at_12f6684
- - loadersun.misc.LauncherExtClassLoader_at_f38798
-
- dumpLoader("system", ClassLoader.getSystemClassLoa
der()) -
- 'system' loadersun.misc.LauncherAppClassLoader_at_1
2f6684 - - loadersun.misc.LauncherExtClassLoader_at_f38798
35Client Applications
- Packaged as a part of an EAR
- inside client-specific ears
- provides clear client/server packaging separation
- inside server-side ear
- provides convenient single packaging
- assumes server-side ear is available to clients
- Execute in their own JVMs
- uses a very lightweight client container
- security
- JNDI, including javacomp/env
- UserTransaction optional
36Client Application Form
- Package the Client code in the form of a JAR file
- include a META-INF/application-client.xml
- Register the JAR file in the EARs
application.xml - J2EE does not specify the remaining deployment of
the Client Application - WLS
- Supply a manifest entry that identifies the main
class - Main-Class ltclient main package.Classgt
- Supply a component.runtime.xml in same
directory as ear - Run the client deployer tool to extract jar
file(s) from ear - java weblogic.ClientDeployer earDir/ear
clientApp - Run the client application
- java weblogic.j2eeclient.Main clientApp.jar url
args
37application-client.xml Example
- lt!DOCTYPE application-client PUBLIC
- "-//Sun Microsystems, Inc.//DTD J2EE
Application Client 1.3//EN" - "http//java.sun.com/dtd/application-client_1_3.
dtd"gt - ltapplication-clientgt
- ltdisplay-namegthelloClientlt/display-namegt
- ...
- lt/application-clientgt
38application-client.xml ENC Values EJB
References
- ltenv-entrygt
- ltenv-entry-namegtnamelt/env-entry-namegt
- ltenv-entry-valuegtvaluelt/env-entry-valuegt
- ltenv-entry-typegtjava.lang.Typelt/env-entry-type
gt - lt/env-entrygt
- ltejb-refgt
- ltejb-ref-namegtejb/HelloNameRemoteHomelt/ejb-r
ef-namegt - ltejb-ref-typegtjavax.ejb.Sessionlt/ejb-ref-typ
egt - lthomegthelloname.HelloNameRemoteHomelt/homegt
- ltremotegthelloname.HelloNameRemotelt/remotegt
- ltejb-linkgtHelloNameEJBlt/ejb-linkgt
- lt/ejb-refgt
39application-client.xml Resource References
- ltresource-refgt
- ltres-ref-namegtnamelt/res-ref-namegt lt!--
example jdbc/mydb --gt - ltres-typegttypelt/res-typegt
lt!-- ex javax.sql.DataSource --gt - ltres-authgtContainerlt/res-authgt
- lt/resource-refgt
40helloClientCA.runtime.xml
- ltapplication-clientgt
- ltejb-refgt
- ltenv-entry-namegtejb/HelloNameRemoteHomelt/env
-entry-namegt - ltjndi-namegtsimpleApp/HelloNameRemoteHomelt/j
ndi-namegt - lt/ejb-refgt
- lt/application-clientgt
41Client Application Example
- helloClientCA/META-INF/MANIFEST.MF
- Manifest-Version 1.0
- Class-Path . helloNameClient.jar
- Main-Class clientapp.HelloClient
- jar tf simpleClientApp.ear
- META-INF/application.xml
- helloNameClient.jar
- Generated by weblogic ejbc compiler
- helloClientCA.jar
42Client Application Example
- public class HelloClient
- public static void main(String args) throws
Exception - String first args0
- String last args1
- Name name new Name(first, last)
- System.out.println("hello " name " from
client") - InitialContext jndi new InitialContext()
- Object object jndi.lookup("javacomp/env/e
jb/HelloNameRemoteHome") - HelloNameRemoteHome home
(HelloNameRemoteHome) - PortableRemoteObject.narrow(object,
HelloNameRemoteHome.class) - HelloNameRemote hello home.create()
- System.out.println(hello.speak(name) "
from EJB")
43Running Client Application Example
- Extract the Client Application Component
- weblogic.ClientDeployer simpleApp.ear
helloClientCA - Run the Client Application
- java -classpath CLASSPATH helloClientCA.jar
weblogic.j2eeclient.Main helloClientCA.jar
t3//localhost7001 jim - binding ClusterableRemoteRef(192.168.1.103
192.168.1.103)/277 of class Proxy1as
ejb/HelloNameRemoteHome - loading class clientapp.HelloClient
- hello jim from client
- hello jim - How you doing! from EJB
44Building J2EE Applications
- using the COREDEV Build System
45Project/Build System Relationship
PROJECT_ROOT(A)
PROJECT_ROOT(B)
builds
builds
uses
uses
PROJECT_HOME
PROJECT_HOME
uses
uses
COREDEV_HOME
46COREDEV_HOME
- ./bin
- ./bin/antfiles
- ./config
- ./config/templates
- ./doc
- ./etc
- ./etc/corebuild
- ./etc/coredev
- ./etc/dtds
- ./javadoc
- ./lib
- ./pubsrc
- ./pubsrc/dd
- ./pubsrc/java
- ./software
- ./software/apache-ant-1.6.2
- ./srczip
47PROJECT_ROOT
- ./build
- ./build/simpleApp
- ./deploy
- ./deploy/bin
- ./deploy/ddl
- ./deploy/doc
- ./deploy/ear
- ./deploy/ejb
- ./deploy/etc
- ./deploy/javadoc
- ./deploy/lib
- ./deploy/pubsrc
- ./deploy/srczip
- ./deploy/war
- ./docsrc
- ./docsrc/doc
- ./etc
- ./etc/simpleProject
- ./src
PROJECT_HOME
48PROJECT_ROOT
- Primary Directories
- src
- location for all developed source code
- placed under CM
- build
- scratch area for building components
- stage
- staging area for applications
- can be deployed to development server
- deploy
- contains final deployment products
- Support Directories
- bin
- build system bootstrap/wrapper scripts
- placed in shells PATH
- etc
- build system property files
- core build system scripts
- dtds
- templates
- software
- dependent archives
- docsrc
- product documentation
projects created in build system using
COREDEV_HOME/bin/coredev templates createProject
49Source (src) Directory
- divided into units
- App J2EE EAR (ex. simpleApp)
- Lib packaging of components (ex. corej2eeLib)
- nearly identical to the App except not deployed
to the application server - units divided into components
- Util utility class archive (ex. helloUtil,
corej2eeUtil) - EJB EJB component (ex. helloWorldEJB,
helloNameEJB) - WEB Web component (ex. simpleWEB)
- CA J2EE Client Application (ex. helloNameCA)
- units created in build system using
- COREDEV_HOME/bin/coredev templates createUnit
50Example Application Unit
- src/simpleApp
- root of unit
- src/simpleApp/META-INF
- contains applications deployment descriptor
(application.xml) - src/simpleApp/bin
- runtime script files (ex. bin/antfiles/simpleApp.x
ml) - src/simpleApp/build.xml
- build script file which mainly invokes component
builds in a specific order - src/simpleApp/helloEJB
- an example EJB Component
- src/simpleApp/helloNameEJB
- src/simpleApp/helloUtil
- src/simpleApp/helloWorldEJB
- src/simpleApp/simpleWEB
- an example Web Component
51Example Lib Unit
- find src/corej2eeLib -maxdepth 1 sort
- src/corej2eeLib
- root of unit
- src/corej2eeLib/bin
- runtime script files
- src/corej2eeLib/build.xml
- build script file which mainly invokes component
builds in a specific order - src/corej2eeLib/config
- runtime configuration files
- src/corej2eeLib/corej2eeUtil
- an example Utility Class Archive Component
- There is no META-INF/application.xml for a Lib
52Non-Web Directories
- Java resources
- classes
- property files
- META-INF
- deployment descriptor(s)
- MANIFEST.MF
- config
- runtime configuration files
- ddl
- database administration scripts
- bin, bin/antfiles
- runtime script files
53Example Utility Class Archive Directory
- find simpleApp/helloUtil/ grep -v CVS sort
- simpleApp/helloUtil/
- base directory of component
- simpleApp/helloUtil/META-INF
- base directory for deployment descriptors
- simpleApp/helloUtil/META-INF/MANIFEST.MF
- identifies metadata (including Class-Path) for
archive - simpleApp/helloUtil/build.xml
- build script for component
- simpleApp/helloUtil/util/Name.java
- example utility Java class
- simpleApp/helloUtil/util/hello.properties
- example utility Java resource file
54Example EJB Directory
- find simpleApp/helloWorldEJB/ grep -v CVS
sort - simpleApp/helloWorldEJB/
- simpleApp/helloWorldEJB/META-INF
- simpleApp/helloWorldEJB/META-INF/MANIFEST.MF
- simpleApp/helloWorldEJB/META-INF/ejb-jar.xml
- simpleApp/helloWorldEJB/META-INF/jboss.xml
- simpleApp/helloWorldEJB/META-INF/weblogic-ejb-jar.
xml - simpleApp/helloWorldEJB/build.xml
- simpleApp/helloWorldEJB/helloworld
- simpleApp/helloWorldEJB/helloworld/HelloWorldEJB.j
ava - simpleApp/helloWorldEJB/helloworld/HelloWorldRemot
e.java - simpleApp/helloWorldEJB/helloworld/HelloWorldRemot
eHome.java
55Example EJB Directory (with ddl)
- find simpleApp/helloEJB/ grep -v CVS sort
- simpleApp/helloEJB/
- simpleApp/helloEJB/META-INF/MANIFEST.MF
- simpleApp/helloEJB/META-INF/ejb-jar.xml
- simpleApp/helloEJB/META-INF/jboss.xml
- simpleApp/helloEJB/META-INF/jbosscmp-jdbc.xml
- simpleApp/helloEJB/META-INF/weblogic-cmp-rdbms-jar
.xml - simpleApp/helloEJB/META-INF/weblogic-ejb-jar.xml
- simpleApp/helloEJB/build.xml
- simpleApp/helloEJB/ddl
- simpleApp/helloEJB/ddl/simpleApp_create.ddl
- simpleApp/helloEJB/ddl/simpleApp_delete.ddl
- simpleApp/helloEJB/ddl/simpleApp_drop.ddl
- simpleApp/helloEJB/ddl/simpleApp_select.ddl
- simpleApp/helloEJB/hello
- simpleApp/helloEJB/hello/HelloEJB.java
56Web Component Directories
- Web Resources
- HTML
- JSPs
- Images
- WEB-INF
- deployment descriptor(s)
- classes
- source specific to Web Component
- lib
- archives specific to Web Component
57Example Web Component Directory
- find simpleApp/simpleWeb/ grep -v CVS sort
- simpleApp/simpleWeb/
- simpleApp/simpleWeb/WEB-INF
- simpleApp/simpleWeb/WEB-INF/classes
- simpleApp/simpleWeb/WEB-INF/classes/hello
- simpleApp/simpleWeb/WEB-INF/classes/hello/web
- simpleApp/simpleWeb/WEB-INF/classes/hello/web/Hell
oServlet.java - simpleApp/simpleWeb/WEB-INF/classes/helloname
- simpleApp/simpleWeb/WEB-INF/classes/helloname/web
- simpleApp/simpleWeb/WEB-INF/classes/helloname/web/
HelloNameServlet.java - simpleApp/simpleWeb/WEB-INF/classes/helloweb
- simpleApp/simpleWeb/WEB-INF/classes/helloweb/Hello
WebServlet.java -
- simpleApp/simpleWeb/WEB-INF/web.xml
- simpleApp/simpleWeb/build.xml
- simpleApp/simpleWeb/displayMessage.jsp
- simpleApp/simpleWeb/index.jsp
58Build (build) Directory
- Scratch area for building components
- Example
- find build/simpleApp/helloWorldEJB -type f
sort - build/simpleApp/helloWorldEJB/META-INF/MANIFEST.MF
- build/simpleApp/helloWorldEJB/META-INF/ejb-jar.xml
- build/simpleApp/helloWorldEJB/META-INF/jboss.xml
- build/simpleApp/helloWorldEJB/META-INF/weblogic-ej
b-jar.xml - build/simpleApp/helloWorldEJB/helloworld/HelloWorl
dEJB.class - build/simpleApp/helloWorldEJB/helloworld/HelloWorl
dRemote.class - build/simpleApp/helloWorldEJB/helloworld/HelloWorl
dRemoteHome.class
59Stage (stage) Directory
- Exploded EAR for deployment to development server
- Example
- find stage/wls/simpleApp
- stage/wls/simpleApp
- stage/wls/simpleApp/helloEJB.jar
- stage/wls/simpleApp/helloNameEJB.jar
- stage/wls/simpleApp/helloUtil.jar
- stage/wls/simpleApp/helloWorldEJB.jar
- stage/wls/simpleApp/META-INF
- stage/wls/simpleApp/META-INF/application.xml
- stage/wls/simpleApp/simpleWEB
- stage/wls/simpleApp/simpleWEB/displayMessage.jsp
- stage/wls/simpleApp/simpleWEB/index.jsp
- stage/wls/simpleApp/simpleWEB/WEB-INF
- stage/wls/simpleApp/simpleWEB/WEB-INF/classes/hell
o/web/HelloServlet.class
60Deploy (deploy) Directory
- Deployment-ready location for built products
- Example
- deploy/bin/antfiles/helloClient.xml
- deploy/bin/antfiles/simpleApp.xml
- deploy/bin/antfiles/tools.xml
- deploy/bin/corej2ee
- deploy/bin/corej2ee.bat
- deploy/config/default.site.properties
- deploy/config/pointbase.ini
- deploy/config/runtime.properties
- deploy/ddl/simpleApp_create.ddl
- deploy/ddl/simpleApp_delete.ddl
- deploy/ddl/simpleApp_drop.ddl
- deploy/ddl/simpleApp_select.ddl
- deploy/ear/wls/simpleApp.ear
- deploy/ear/wls/simpleClientApp.ear
- deploy/ejb/helloWorldEJB.jar
- deploy/ejb/wls/helloWorldEJB.jar
- deploy/lib/corej2ee.jar
61Automating J2EE Application Creation with Ant
- Jakarta project
- Apache Ant Home Page
- http//jakarta.apache.org/ant/
- Java-based build tool
- Make-like tools are inherently shell-based
- extend these tools by using or writing any
program for the OS that you are working on - Ant is extended using Java classes
- uses declarative configuration files versus
scripts
62Core Ant Files
- ANT_HOMECOREDEV_HOME/software/apache-ant-1.6.2
bin
ant antRun antenv.cmd lcp.bat
runrc.cmd ant.bat antRun.bat
complete-ant-cmd.pl runant.pl ant.cmd antRun.pl
envset.cmd runant.py
lib
GenJar.jar ant-jai.jar
ant-vaj.jar README
ant-javamail.jar ant-weblogic.jar ant-antlr.jar
ant-jdepend.jar ant-xalan1.jar ant-a
pache-bcel.jar ant-jmf.jar
ant-xslp.jar ant-apache-bsf.jar
ant-jsch.jar ant.jar ant-apache-log4j.jar
ant-junit.jar bcel-5.1.jar ant-apache-oro.j
ar ant-launcher.jar commons-net-1.2.2.jar
ant-apache-regexp.jar ant-netrexx.jar
jakarta-oro-2.0.8.jar ant-apache-resolver.jar
ant-nodeps.jar jsch-0.1.16.jar ant-commons-log
ging.jar ant-starteam.jar xercesImpl.jar ant-co
mmons-net.jar ant-stylebook.jar
xml-apis.jar ant-contrib-1.0b1.jar
ant-swing.jar ant-icontract.jar
ant-trax.jar
63Wrapping Ant (COREDEV_HOME/bin/ant)
- if -z "MYSITE_PROPERTIES" then
- MYSITE_PROPERTIESHOME/mysite.properties
- fi
- defines the location for personal overrides
- if -n "ANT_OPTS" then
- export ANT_OPTS'-Xms64m -Xmx96m'
- fi
- attempts to establish an environment sized to
complete large recursive builds - export PATH"JAVA_HOME/bin/usr/binPATH"
- exec ANT_HOME/bin/ant \
- -DJAVA_HOME"JAVA_HOME" \
- -DMYSITE_PROPERTIES"MYSITE_PROPERTIES" \
- "COREDEV_HOME_PROP" \
- -find build.xml \
- -logger org.apache.tools.ant.NoBannerLogger \
- _at_
- -D defines ant properties applied to script files
- "COREDEV_HOME_PROP" sets a
DCOREDEV_HOME(dir) if COREDEV_HOME defined - -find specifies to search from current to root
parent for a file called build.xml
64Unit/Component Antfiles
- find src/simple -name build.xml sort
- src/simpleApp/build.xml
- src/simpleApp/helloEJB/build.xml
- src/simpleApp/helloNameEJB/build.xml
- src/simpleApp/helloUtil/build.xml
- src/simpleApp/helloWorldEJB/build.xml
- src/simpleApp/simpleWEB/build.xml
- src/simpleClientApp/build.xml
- src/simpleClientApp/helloClientCA/build.xml
65build.xml Basics
XML Root Element
- ltproject name"helloWorldEJB" default"all"
basedir".."gt - ltproperty name"ejbname" value"helloWorld"/gt
- ltproperty name"ejbfile" value"ejbnameEJB"/
gt - ltproperty file"basedir/app.properties"/gt
- ltproperty file"basedir/../site.properties"/
gt - ltproperty file"basedir/../build.properties"
/gt -
- lttarget name"all"
depends"build"/gt - lttarget name"build" depends"compile"
description"builds ejb.jar file"gt - ltecho messagebuilding /gt
- lt/targetgt
- lt/projectgt
Base directory for all path calculations
properties can be literal values
properties can be built from other properties
properties can be loaded from a file
one target is the default target
targets have names and are invoked by ant
lttarget namegt
targets can have dependencies on other targets
targets have ant tasks
66COREDEV build.xml Basics
COREDEV_HOME imports contain most of build
logic
- ltproject name"simpleApp" default"all"
basedir"."gt - ltimport file"COREDEV_HOME/etc/corebuild/co
rebuild_unit.xml" /gt - ltproperty name"components"
- value"helloUtil,helloWorldEJB,helloEJB,hel
loNameEJB,simpleWEB"/gt - lt/projectgt
element-specific Ant properties
67COREDEV_HOME/etc/corebuild
- corebuild.properties
- corebuild_archive.xml
- corebuild_common.xml
- corebuild_component.xml
- corebuild_copy.xml
- corebuild_delegate.xml
- corebuild_distribute.xml
- corebuild_docsrc.xml
- corebuild_ejb.xml
- corebuild_etc.xml
- corebuild_ftp.xml
- corebuild_generic.xml
- corebuild_java.xml
- corebuild_javadoc.xml
- corebuild_jboss.xml
- corebuild_properties.xml
- corebuild_root.xml
- corebuild_rsync.xml
- corebuild_scp.xml
- corebuild_software.xml
- corebuild_software_root.xml
- corebuild_src.xml
- corebuild_support.xml
- corebuild_unit.xml
- corebuild_util.xml
- corebuild_war.xml
- corebuild_wls.xml
- corebuild_xdoclet.xml
- corebuild_xml.xml
- package.properties
- unix.properties
- windows.properties
- xdoclet.properties
68corebuild_properties.xml
- lt!-- 1) read in the user's local override file
--gt - ltproperty file"MYSITE_PROPERTIES"/gt
- lt!-- 2) read in the project's site-specific
property files from a - host, os, and generic site perspective. Just
like MYSITE_PROPERTIES, - these files should not be supplied in any
delivery. A site should - be able to use these files to help configure
the property files - that come later.
- --gt
- lt!-- contains host-specific paths and
properties for project --gt - ltproperty file"PROJECT_ETC/site.hostname.pr
operties"/gt - lt!-- contains os-specific paths and
properties for project --gt - ltproperty file"PROJECT_ETC/site.osName.prop
erties"/gt - lt!-- contains family-specific paths and
properties for project --gt - ltproperty file"PROJECT_ETC/site.osFamily.pr
operties"/gt - lt!-- contains os-neutral paths to packages
for project --gt - ltproperty file"PROJECT_ETC/site.properties"/gt
69corebuild_properties.xml
- lt!-- 3) read in the project's site-neutral
property files from an os - and os-neutral perspective. These files will
be supplied as part - of the project's product and should not be
modified on site. - --gt
- ltproperty file"PROJECT_ETC/osName.propertie
s"/gt - ltproperty file"PROJECT_ETC/osFamily.propert
ies"/gt
70corebuild_properties.xml
- lt!-- 4) read in the build system's site-neutral
property files from - an os-specific and os-neutral perspective. These
files will be supplied - as part of the build system and should not be
modified on site. - --gt
- ltproperty file"COREBUILD_ETC/osName.propert
ies"/gt - ltproperty file"COREBUILD_ETC/osFamily.prope
rties"/gt - lt!-- 5) now read in the platform neutral
properties. Start with the - corebuild to make it easier to build
project.properties --gt - ltproperty file"PROJECT_ETC/corebuild.propertie
s"/gt - ltproperty file"COREBUILD_ETC/corebuild.propert
ies"/gt - lt!-- 6) read in the definitions for the package
extensions --gt - ltproperty file"PROJECT_ETC/package.properties"
/gt - ltproperty file"COREBUILD_ETC/package.propertie
s"/gt - ltproperty file"PROJECT_ETC/project.properties"
/gt
71Extending Targets
- ltproject name"corebuild_properties"gt
- lttarget name"env"gt
- ltechogtAPP_VERSIONAPP_VERSIONlt/echogt
- ltechogtCOREDEV_HOMECOREDEV_HOMElt/echogt
- lt/targetgt
- ltimport file"COREDEV_HOME/etc/corebuild/corebu
ild_properties.xml"/gt - lttarget name"env"
- depends"check,corebuild_properties.env"
- description"displays key environment
properties"gt - ltechogttargetTypestargetTypeslt/echogt
- lt_implTarget_ target"env"/gt
- lt/targetgt
72Using Macros
- ltmacrodef name"_callddl_"gt
- ltattribute name"base" default"ddlBase"/gt
- ltattribute name"command"/gt
- ltsequentialgt
- ltfor param"i" list"_at_base"gt
- ltsequentialgt
- ltant antfile"COREDEV_HOME/bin/antf
iles/coredev_tools.xml" - dir"basedir"
- target"ddl"gt
- ltproperty name"name"
value"_at_i__at_command"/gt - lt/antgt
- lt/sequentialgt
- lt/forgt
- lt/sequentialgt
- lt/macrodefgt
- lttarget name"dbcreate"
- if"ddlBase"
- description"creates db tables"gt
73Example Target
- lttarget name"_compile_" depends"init, _import_"
description"compiles java files" gt - ltproperty name"java.excludes" value""/gt
- ltjavac srcdir"src" destdir"classes"
debug"on includes"//.java
excludes"java.excludes"gt - ltclasspathgt
- ltpath refid"ear.classpath"/gt
- ltpath refid"external.classpath"/gt
- ltpathelement path"J2EE_CLASSES"/gt
- ltpathelement path"classes"/gt
- lt/classpathgt
- lt/javacgt
- ltcopy todir"classes"gt
- ltfileset dir"src" includes"META-INF/.x
ml"/gt - ltfileset dir"src" includes"/.propert
ies"/gt - ltfileset dir"src" includes"/.xml"
excludes"build.xml,config//,bin//"/gt - lt/copygt
- ltjar destfile"EJB_DIR/ejbfile.jar
manifest"classes/META-INF/MANIFEST.MF"gt - ltfileset dir"APP_BUILD_DIR/ejbfile
excludes"META-INF/MANIFEST.MF"/gt
74Deploying J2EE Applications
75Deployable EAR Archive
jar tf ear/simpleApp.ear META-INF/MANIFEST.MF ME
TA-INF/application.xml helloUtil.jar helloWorldEJ
B.jar helloEJB.jar helloNameEJB.jar simpleWEB.war
Utility classes usable by all EJBsand Web
Applications inside EAR
EJB Components
Web Application
76Deployable EAR Archive
jar tf ear/simpleClientApp.ear META-INF/MANIFEST
.MF META-INF/application.xml helloClientCA.jar
helloNameClient.jar
Client Application
- EJB Client Jar Files
- built during optional EJB
- compilation
- used for clients running external to EAR
77Deployable EAR (exploded) Directory
cd simpleApp find . ./META-INF/application.xml
./helloUtil.jar ./helloWorldEJB.jar ./helloEJB.j
ar ./helloNameEJB.jar ./simpleWEB.war
Utility classes usable by all EJBsand Web
Applications inside EAR
EJB Components
Web Application
78Deployable EAR (exploded) Directory
cd simpleApp find . ./META-INF/application.xml
./helloClientCA.jar ./helloNameClient.jar
Client Application
- EJB Client Jar Files
- built during optional EJB
- compilation
- used for clients running external to EAR
79Deploying WAR as a Directory inside EAR
find ./simpleWEB ./simpleWEB ./simpleWEB/WEB-INF
/classes ./simpleWEB/WEB-INF/classes/helloname ./s
impleWEB/WEB-INF/classes/helloname/web ./simpleWEB
/WEB-INF/classes/helloname/web/HelloNameServlet.cl
ass ./simpleWEB/WEB-INF/classes/hello ./simpleWEB/
WEB-INF/classes/hello/web ./simpleWEB/WEB-INF/clas
ses/hello/web/HelloServlet.class ./simpleWEB/WEB-I
NF/classes/helloworld ./simpleWEB/WEB-INF/classes/
helloworld/web ./simpleWEB/WEB-INF/classes/hellowo
rld/web/HelloWorldServlet.class ./simpleWEB/WEB-IN
F/classes/helloweb ./simpleWEB/WEB-INF/classes/hel
loweb/HelloWebServlet.class ./simpleWEB/WEB-INF/we
b.xml ./simpleWEB/WEB-INF/REDEPLOY ./simpleWEB/WEB
-INF/weblogic.xml ./simpleWEB/index.jsp ./simpleWE
B/displayMessage.jsp
cat META-INF/application.xml ltapplicationgt ... lt
modulegt ltwebgt ltweb-urigtsimpleWEBlt/web-ur
igt ltcontext-rootgtsimpleApplt/context-rootgt
lt/webgt lt/modulegt lt/applicationgt
80Deploying WAR as an Archive inside EAR
jar tf simpleWEB.war META-INF/ META-INF/MANIFEST
.MF WEB-INF/weblogic.xml WEB-INF/classes/ WEB-INF/
classes/helloname/ WEB-INF/classes/helloname/web/
WEB-INF/classes/helloname/web/HelloNameServlet.cla
ss WEB-INF/classes/hello/ WEB-INF/classes/hello/we
b/ WEB-INF/classes/hello/web/HelloServlet.class WE
B-INF/classes/helloworld/ WEB-INF/classes/hellowor
ld/web/ WEB-INF/classes/helloworld/web/HelloWorldS
ervlet.class WEB-INF/classes/helloweb/ WEB-INF/cla
sses/helloweb/HelloWebServlet.class index.jsp disp
layMessage.jsp WEB-INF/web.xml
cat META-INF/application.xml ltapplicationgt ... lt
modulegt ltwebgt ltweb-urigtsimpleWEB.warlt/we
b-urigt ltcontext-rootgtsimpleApplt/context-root
gt lt/webgt lt/modulegt lt/applicationgt
81Deploying EJB as an Archive inside EAR
jar tf helloWorldEJB.jar META-INF/MANIFEST.MF ME
TA-INF/ META-INF/ejb-jar.xml META-INF/weblogic-ejb
-jar.xml helloworld/ helloworld/HelloWorldRemote.c
lass helloworld/HelloWorldEJB.class helloworld/Hel
loWorldRemoteHome.class helloworld/HelloWorldEJB_l
dzvb1_HomeImplRTD.xml helloworld/HelloWorldEJB_ldz
vb1_EOImplRTD.xml helloworld/HelloWorldEJB_ldzvb1_
EOImpl.class helloworld/HelloWorldEJB_ldzvb1_HomeI
mpl.class helloworld/HelloWorldEJB_ldzvb1_Impl.cla
ss
cat META-INF/application.xml ltapplicationgt ...
cat META-INF/application.xml ltapplicationgt
ltdisplay-namegtSimple Applt/display-namegt
ltmodulegt ltejbgthelloWorldEJB.jarlt/ejbgt
lt/modulegt ... lt/applicationgt
82Deploying EJB as a Directory inside EAR
find helloWorldEJB/ META-INF/MANIFEST.MF META-IN
F/ejb-jar.xml META-INF/weblogic-ejb-jar.xml helloW
orldEJB/ helloWorldEJB/helloworld helloWorldEJB/he
lloworld/HelloWorldRemote.class helloWorldEJB/hell
oworld/HelloWorldRemoteHome.class helloWorldEJB/he
lloworld/HelloWorldEJB.class
cat META-INF/application.xml ltapplicationgt ...
cat META-INF/application.xml ltapplicationgt
ltdisplay-namegtSimple Applt/display-namegt
ltmodulegt ltejbgthelloWorldEJBlt/ejbgt
lt/modulegt ... lt/applicationgt
83Deploying the EAR
As a File
As a Directory
84Configure and Deploy EAR
85Deploying Components
86Take a Test Drive
87Taking a Test Drive