Upload
oraclegeek007
View
217
Download
0
Embed Size (px)
Citation preview
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 1/42
Copyright © 2009, Oracle. All rights reserved.
Deploying Java EE Applications
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 2/42
Copyright © 2009, Oracle. All rights reserved.11 - 2
Objectives
After completing this lesson, you should be able to:
Describe Java EE Web applications
Describe Enterprise Deployment Architectures
Package Web applications in several forms
Define Web application structure and Web application
archive
Explain why WebLogic augments standard Java EEdeployment descriptors with weblogic*.xml files
Look at deployment descriptors web.xml andweblogic.xml
Describe URLs and Web applications
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 3/42
Copyright © 2009, Oracle. All rights reserved.11 - 3
Road Map
Web applications
± Web applications
± Directory structure and deployment descriptors
± Using the Console to deploy Web applications
± Monitoring Web applications
EJB applications
Enterprise applications
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 4/42
Copyright © 2009, Oracle. All rights reserved.11 - 4
Java EE Web Applications
Web application:
± Responds to client requests using the HTTP protocol
± Typically implements an interactive Web site
The contents of a Web application can include:
± Java servlets
± JavaServer Pages (JSPs) for dynamic content
± Static content (HTML, CSS, images, and so on)
± Java classes and libraries
± Client-side libraries (JavaScript, Java Applets, and so on)
± XML deployment descriptors:
² Standard (web.xml)
² WebLogic specific (weblogic.xml)
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 5/42
Copyright © 2009, Oracle. All rights reserved.11 - 5
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 6/42
Copyright © 2009, Oracle. All rights reserved.11 - 6
Packaging Web Applications
You should package an application before it can be deployed to
Oracle WebLogic Server. To appropriately package a Web
application, perform the following steps:
1. Arrange the resources in a prescribed directory structure.
2. Develop or copy the web.xml deployment descriptor (optional).
3. Develop or copy the weblogic.xml deployment
descriptor (optional and WLS specific).
4. Archive the Web application into a .war file using Java
Archive (JAR).
5. Deploy the Web application onto Oracle WebLogic Server.
6. Configure the Web application with the Oracle WebLogic
Server Administration Console.
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 7/42
Copyright © 2009, Oracle. All rights reserved.11 - 7
Web Application Structure
Directory or File Description
Public document root of Web application
Private resources not served directly to clients
Classes, such as servlets, filters, listeners
Java libraries (JAR files)Optional Java EE deployment descriptor
Optional WebLogic deployment descriptor
Static and dynamic Web content
MyWebApp.war
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 8/42
Copyright © 2009, Oracle. All rights reserved.11 - 8
Web Application Archive
Web archives are created using the jar utility:
jar
.war
Static resources:
HTML, text images
HTMLHTML
web.xml
weblogic.xml
Deployment
descriptors JSPs
JSP
JSPJSPServlets, JavaBeans,
and other classes
Servlet
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 9/42
Copyright © 2009, Oracle. All rights reserved.11 - 9
Optional Configuration of Web Applications
Web applications can be specified in web.xml and
weblogic.xml deployment descriptors. The configurations
include:
Defining the run-time environment
Mapping URLs to servlets and JSPs Defining application defaults such as welcome and error
pages
Specifying Java EE security constraints
Defining work managers for applications Setting the context root for the application
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 10/42
Copyright © 2009, Oracle. All rights reserved.11 - 10
web.xml
The web.xml file is used to configure the following:
Servlets and JSP registration
Servlet initialization parameters
JSP tag libraries
MIME type mappings
Welcome file list
Error pages
Security constraints and roles
Resources
EJB references
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 11/42
Copyright © 2009, Oracle. All rights reserved.11 - 11
weblogic.xml
Using weblogic.xml, you can configure the following:
The application¶s root context path
Application logging
Security role mappings
Advanced session settings
Session clustering
References to shared libraries
References to server resources (data sources, EJBs, and
so on) Work managers and threading
Virtual directories
JSP compiler options
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 12/42
Copyright © 2009, Oracle. All rights reserved.11 - 12
<?xml version='1.0' encoding='utf-8'?> < weblogic-web-app
xmlns="http://xmlns.oracle.com/weblogic/weblogi
c-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema
-instance">
</ weblogic-web-app>
weblogic.xml Deployment Descriptor
Example of the weblogic.xml deployment descriptor:
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 13/42
Copyright © 2009, Oracle. All rights reserved.11 - 13
URLs and Web Applications
The URL that is used to reference a resource in a Web
application must include the name of the Web application.
Accessing a resource in a Web application:http://hostname: port/ MyWebApplication/resource
Where:
H ostname Host name mapped to virtual host or hostname:port
MyWebApplicationName of the Web application; not necessary if this
is the default Web application
resource Static page, servlet mapping, or JSP
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 14/42
Copyright © 2009, Oracle. All rights reserved.11 - 14
Web Service Applications
A Web service application:
Responds to HTTP client requests using the Simple Object
Access Protocol (SOAP)
Uses the same structure as a Java EE Web application
Supports two additional deployment descriptors: ± webservices.xml
± weblogic-webservices.xml
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 15/42
Copyright © 2009, Oracle. All rights reserved.11 - 15
Virtual Directory Mappings
Virtual directories:
Can be used to refer to physical directories
Enable you to avoid the need to hard-code paths to
physical directories
Allow multiple Web applications to share common physicaldirectories for specific requests such as images
Decrease duplication of files across applications
Are configured in weblogic.xml
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 16/42
Copyright © 2009, Oracle. All rights reserved.11 - 16
<virtual-directory-mapping>
<local-path> c:/usr/gifs </local-path>
<url-pattern>/images/*</url-pattern>
<url-pattern>*.j pg </url-pattern>
</virtual-directory-mapping>
<virtual-directory-mapping>
<local-path> c:/usr/common_ jsps.jar </local-path>
<url-pattern>*.jsp </url-pattern>
</virtual-directory-mapping>
Virtual Directory Mapping: Example
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 17/42
Copyright © 2009, Oracle. All rights reserved.11 - 17
Road Map
Web applications
EJB applications
± Major EJB types and their purpose
± EJB deployment descriptor files
Enterprise applications
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 18/42
Copyright © 2009, Oracle. All rights reserved.11 - 18
EJB Applications
Enterprise JavaBeans (EJBs):
Standardize the development and deployment of server-
side distributed components
Are annotated Java classes
Are packaged with XML deployment descriptors
Support the following capabilities:
± Remote access over a network
± Object-relational mapping via WLS or the Java Persistence
API (JPA)
± Transactions
± Messaging integration
± Dependency injection
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 19/42
Copyright © 2009, Oracle. All rights reserved.11 - 19
Types of EJBs
EJB Type Description Example
Stateless Session
Do not maintain state
Are synchronous
Are maintained in memory
Check validity of stocksymbol
Calculate billing of aphone call
Stateful Session
Offer conversational interaction
Maintain state for client
Are synchronous
Book a flight & car rentalfor travel
Manage a shopping cart
Entity Represent persisted data
Are synchronous
Represent a player¶sstatistics
Represent a stock¶shistory
Message-Driven Are asynchronous & stateless
Consume JMS messages Store logging messages
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 20/42
Copyright © 2009, Oracle. All rights reserved.11 - 20
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 21/42
Copyright © 2009, Oracle. All rights reserved.11 - 21
EJB Application Structure
Directory or File Description
Application root folder
Java classes organized into packages
EJB and other Java class files
Meta-information folder
Optional Java EE and JPA deployment
descriptors
Optional WebLogic deployment
descriptors
MyEJBApp.jar
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 22/42
Copyright © 2009, Oracle. All rights reserved.11 - 22
weblogic-ej b-jar.xml
Using weblogic-ejb-jar.xml, you can configure:
Security role mappings
Advanced security settings
EJB clustering
EJB pooling and caching
Work managers and threading
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 23/42
Copyright © 2009, Oracle. All rights reserved.11 - 23
Administrator Tasks with EJBs
The administrator tasks for EJBs include:
Configuring and deploying
Resolving JNDI and other infrastructure issues
Monitoring EJB caches and pools
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 24/42
Copyright © 2009, Oracle. All rights reserved.11 - 24
Road Map
Web applications
EJB applications
Enterprise applications
± Enterprise application concepts
± Enterprise Archive (.ear) file structure
± Enterprise application configuration
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 25/42
Copyright © 2009, Oracle. All rights reserved.11 - 25
What Is an Enterprise Application?
An enterprise application is a grouping of several
resources into one deployable unit that is packaged in an.ear file.
These resources include:
± Web applications (.war) ± EJB applications (.jar)
± Java applications (.jar)
± Resource adapters (.rar)
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 26/42
Copyright © 2009, Oracle. All rights reserved.11 - 26
A Typical Java EE System
EJB
application
Web service
application
External
application
Web
application
Web
browser
Data
source
Message
queue
External
application
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 27/42
Copyright © 2009, Oracle. All rights reserved.11 - 27
Java EE Enterprise Application
EJB
Java EE Modules
EJB
EJB
Web
Web
Enterprise Archive
(EAR)
EJB module
(JAR)
Web application
module(WAR)
Application client
module
(JAR)
Resource adapter
module
(RAR)
EJB-JAR
WAR
JAR
RAR
web.xml
weblogic.xml
weblogic-appclient.xml
weblogic-ra.xml
application.xml
weblogic-application.xml
Deployment descriptor
ejb-jar.xmlweblogic-ejb- jar.xml
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 28/42
Copyright © 2009, Oracle. All rights reserved.11 - 28
Java EE Enterprise Application
An enterprise application:
Comprises one or more Java EE application modules:
± Web applications
± EJB applications
± Other Java libraries (JARs)
Allows related applications to be deployed as a unit
Can include application-specific JDBC and JMS resources
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 29/42
Copyright © 2009, Oracle. All rights reserved.11 - 29
Why Enterprise Applications?
Use enterprise applications to:
Avoid namespace clashes
Declare applicationwide security roles
Deploy an application as one unit
Share applicationwide EJB resources
Configure local JDBC data sources
Configure local JMS resources
Configure local XML resources
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 30/42
Copyright © 2009, Oracle. All rights reserved.11 - 30
Enterprise Application Structure
Directory or File Description
Application root folder
Replaces /APP-INF/lib. May contain:
- Common Java class files
- Common Java libraries (JARs)
Optional JEE deployment descriptor
JDBC and JMS modules
Optional WebLogic descriptor
Web and EJB application modules
MyApp.ear
MyApp
T lib
mylib1
mylib2
T META-INF
application.xml
mydatasource-jdbc.xml
myqueue-jms.xml
weblogic-application.xml
EJBApp.jar
WebApp1.war
WebApp2.war
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 31/42
Copyright © 2009, Oracle. All rights reserved.11 - 31
weblogic-application.xml
Using weblogic-application.xml, you can configure:
References to shared libraries
Work managers and threading
Default EJB and Web application parameter values
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 32/42
Copyright © 2009, Oracle. All rights reserved.11 - 32
Application Scoping
Configure enterprisewide WLS-specific features with theweblogic-application.xml deployment descriptor:
XML parsers
XML entity mappings
JDBC data sources JMS connection factories and destinations
Security realms
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 33/42
Copyright © 2009, Oracle. All rights reserved.11 - 33
EAR Class Libraries
Extending the Java 2 EE 1.4 specification, Oracle addedAPP-INF/lib and APP-INF/classes to the standard
Java EE EAR file structure. For Java EE 5, it is preferableto use the /lib directory.
When an application is initialized, the paths extracted areprefixed to the application¶s classpath.
Classes are added to the root classloader of the
application.
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 34/42
Copyright © 2009, Oracle. All rights reserved.11 - 34
Java EE Library Support
Create a library of Java EE modules, package the modules
into an EAR, a WAR, or an EJB file, and then deploy and
register the module with the application container.
Other applications can later use the modules as if they
were packaged in their own EAR, WAR, or EJB files. This allows for more reusability between the applications.
App1.ear
App2.ear
App3.ear
App4.ear
myLibB.ear
myLibA.war
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 35/42
Copyright © 2009, Oracle. All rights reserved.11 - 35
WebLogic Java EE Shared Libraries
A Java EE shared library:
Is a reusable portion of a Web or enterprise application
Is referenced by other deployed applications
Avoids duplicating source files among Java EE projects
Can contain deployment descriptors that are merged withthe application¶s descriptors
WebLibraryA
page1.jsp
lib1.jar
web.xml
WebLibraryB
page2.jsp
web.xml
page1.jsppage2.jsp
page3.jsp
web.xml
DEPLOY
MyWebApp
page1.jsp
page2.jsp
page3.jsp
lib1.jar
web.xml (merged)
MyWebApp
Overrides
library source
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 36/42
Copyright © 2009, Oracle. All rights reserved.11 - 36
Shared Library References
For Web applications, list the required shared libraries inweblogic.xml.
For enterprise applications, list the required shared librariesin weblogic-application.xml.
Excerpts from weblogic.xml::
<library-ref>
<library-name> ajax-tools-lib </library-name>
<specification-version>1.5.0</specification-version>
<implementation-version>2.0.0</implementation-version>
</library-ref>
<library-ref>
<library-name> help-web-lib </library-name>
<specification-version>1.5.0</specification-version>
<implementation-version>1.1.0</implementation-version>
</library-ref>
:
Shared libraryname and version
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 37/42
Copyright © 2009, Oracle. All rights reserved.11 - 37
Quiz
A ____________ is a reusable Oracle WebLogic Server
application that can be referenced by other deployed
applications.
1. Java library
2. Shared library3. Web library
4. Composite library
5. Reference library
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 38/42
Copyright © 2009, Oracle. All rights reserved.11 - 38
Quiz
Which of the following is NOT a supported type of application in
Oracle WebLogic Server?
1. Enterprise application
2. EJB application
3. Process application4. Web service application
5. Web application
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 39/42
Copyright © 2009, Oracle. All rights reserved.11 - 39
Quiz
Which of the following are valid Oracle WebLogic Server
deployment descriptor files for configuring applications?
1. weblogic-webapp.xml
2. weblogic-ejb-jar.xml
3. weblogic.xml4. weblogic-application.xml
5. weblogic-library.xml
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 40/42
Copyright © 2009, Oracle. All rights reserved.11 - 40
Summary
In this lesson, you should have learned how to:
Package and deploy Web applications
Describe deployment descriptors
Explain Enterprise JavaBeans concepts
Configure and deploy EJBs
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 41/42
Copyright © 2009, Oracle. All rights reserved.11 - 41
Practice 11 Overview:
Web Application Deployment Concepts
This practice covers the following topics:
Deploying (installing) prerequisite libraries
Deploying (installing) applications
Starting and stopping applications
Testing applications
Redeploying (updating) applications
Undeploying (deleting) applications
Front-ending applications with a Web server²for example,
Oracle HTTP Server
8/2/2019 Les 11 DeployJavaEE
http://slidepdf.com/reader/full/les-11-deployjavaee 42/42
Copyright © 2009 Oracle All rights reserved11 42