You are on page 1of 45

JBoss Application Server

Administration
Unit 5 – J2EE Applications
Objectives

• At the end of this module you will be


able to:
– Describe the structure of Web applications
– Deploy Web applications
– Configure virtual hosts
– Manage Enterprise JavaBeans
– Deploy Enterprise Applications
Roadmap

1. Web Applications
– Web Applications
– Directory Structure and Deployment
Descriptors
– Deploy Web Applications
2. Enterprise JavaBeans (EJBs)
3. Enterprise Applications
The Role of Web Servers

• Web servers are responsible for handling HTTP


requests from clients.
• Web servers typically return:
– Static content (HTML pages, graphics, …)
– Dynamic content (Servlet, JSPs, CGIs, …)
Static Content

• Static content are documents that are


predefined on the server and do not change.
• WebLogic Server can be used to serve static
content such as:
– HTML documents
– images
– PDF documents

• WebLogic Server can serve static documents:


– over standard HTTP
– through SSL using HTTPS
Dynamic Content

• Dynamic content are documents that may


change based on the client’s request.
• HTML documents can be created on the fly by
using:
– Servlets
– JavaServer Pages (JSPs)
– Common Gateway Interface (CGI) programs
A Typical Web Interaction
MIME Types

• Multipurpose Internet Mail Extensions (MIME) is


a protocol for identifying and encoding binary
data.
• All HTTP response data is encoded with a MIME
content type.
• Browsers interpret HTTP response data
differently depending upon the MIME type of
the data:
– HTML pages are parsed and displayed
– PDF documents can be sent to Adobe Acrobat
– application code can be directly executed
HTTP Status Codes

• HTTP status codes:


– Indicate to the client whether or not the request was
successful
– Provide the client a reason for a failed request
– Used by clients to provide alternate behavior
What is a Web Application ?

• A Web Application is a group of serverside


resources that create an interactive online
application.
• Server-side resources include:
– Servlets (small server-side applications)
– JavaServer Pages (dynamic content)
– Static documents (HTML, images)
– Server-side classes
– Client-side applets and beans
Web Application Structure

• The structure of Web Applications is defined by


the Servlet specification.
• A Web Application can be either:
– an archived file (.war file)
– An expanded directory structure
Packaging and Deploying a Web Application

• Deploying an application consists of configuring it,


packaging it and registering it with a JBoss server.
• To deploy a Web application, follow these steps:

1) Arrange resources in a prescribed directory structure.


2) Develop web.xml Deployment Descriptor.
3) Develop a jboss.xml Deployment Descriptor (JBoss-specific)
4) Archive the Web Application into a WAR file, using JAR.
5) Deploy the Web application onto JBoss
6) Configure the Web Application with JBoss Administration Console

• A Web archive is created using the jar utility


Configuring a Web Application

• A Web application is configured through the


deployment descriptors, web.xml and
weblogic.xml, which perform these tasks:
– Define the run-time environment
– Map URLs to Servlets and JSPs
– Define application defaults, such as welcome
an error pages
– Specify J2EE security constraints
The web.xml file

• The web.xml file is a deployment descriptor for


configuring:
– Servlets and JSP registration
– Servlet initialization parameters
– JSP tag libraries
– MIME type mappings
– welcome file list
– error pages
– define security constraints
The jboss.xml file

• The jboss.xml is a JBoss Server specific


deployment descriptor for configuring:
– JSP properties
– JNDI mappings
– security role mappings
– HTTP session parameters
URL and Web Applications

• The URL used to reference a resource in a Web


Application must include the name of the Web
Application.
Deployment Methods

• JBoss supports these deployment methods:


– Auto-deployment
– Command-line deployment
- You can deploy :
- An enterprise application (*.ear)
- A Web application (*.war)
- An EJB application (*.jar)
- A resource adapter application (*.rar)
An Archive vs. An Expanded Directory

• You archive a web application if:


– It is in production phase
– It is deployed to multiple machines
• You do not archive a web application if:
– It is in development o debugging phase
– The application will be updated frequently
– It is deployed to one machine (an
administration server)
Auto-deployment: Copying Files

• If production mode is off:


– You can install an application, by copying it
(manually, or using the console) to the
domain applications folder
– The Administration Server monitors the
applications folder for new changed or
removed applications
– This configures, targets and deploys the
application to the Administration server only
Section Review

• In this section we learned how to:


– Describe web applications
– Create web application directory structures
– Deploy web applications using the command-
line
Lab Exercise

• Deploy a web application.


– Refer to the lab guide for more details.
– Ask the instructor for any clarification.
– The instructor will determine the stop time.
Road Map

1. Web Applications
2. Enterprise JavaBeans (EJBs)
– Types of EJBs
– Deployment and Monitoring
3. Enterprise Applications
Enterprise JavaBeans

• Enterprise JavaBeans™ (EJB) standardizes the


development and deployment of server
components built in Java.
• The EJB specification defines relationships
between:
– the EJB and its container
– the container and the application server
– the container and the client
Containers

• A container intercepts communication between


the client and the component to allow addition
of infrastructure code.
Types of EJBs

• The EJB specification discusses of objects:


– stateless session beans
– stateful session beans
– entity beans
– message driven beans
What is an Stateless Session Bean

• Stateless session EJBs:


– provide independent services
– do not maintain state on behalf of client
– are synchronous
– do not survive EJB server crashes
– are maintained in memory
– calls can be handled by any instance with the same
results
What is a Stateful Session Bean

• Stateful session EJBs:


– provide conversational interaction
– store state on behalf of the client
– are synchronous
– do not survive EJB server crashes
– are maintained in memory
– each instance is associated to a single client
Session EJB Examples

• Stateless session EJBs: • Stateful session EJBs:

– an EJB that checks to see if a stock


– an EJB that books a flight and car
symbol is valid rental at a travel agents Web site
– an EJB that determines the local billing – an EJB that orders spare parts for a car
price for a phone call an EJB that as part of an application
calculates an insurance quote based on – an EJB that manages the shopping cart
a provided customer profile in a Web site
– an EJB that assembles a standard
report from several departments
Entity Beans

• Entity EJBs have the following behavior:


– they are representations of persistent data
– they can survive a crash
– multiple clients can be using EJBs that represent the
same data
– the EJB manages an in-memory “copy” of the data in
the persistent store
Entity Beans Examples

• Some entity EJB examples include:


– an EJB that represents a football player’s career
statistics
– an EJB that represents a stock’s historical prices
– an EJB that represents a genome sequence
– an EJB that represents the outline for a course
– an EJB that contains your personal profile for
accessing your favorite Web site
Message Driven Beans

• Message driven beans (MDB):


– are asynchronous stateless components
– behave similarly to stateless session beans
– are JMS message consumers
– Clients do not interact directly with MDBs
EJB Application Directory Structure

• EJB components come


packaged in a JAR file.
• The format of the
JAR file is shown
Deployment Descriptors
here:
• EJBs are configured
by modifying the XML
files.
EJB Administration Tasks With JBoss

• You can set up Stateless session EJBs for:


– pool size
• You can configure Stateful session EJBs’:
– cache size
– idle timeout - if memory is short, not used objects
can be disposed of after a certain period of time
– cache type - if memory is short, objects can be stored
to persistent storage (if they are not timed out); this
is called passivation
• Entity EJBs are both pooled and cached, so you can set
their:
– pool size
– cache size and idle timeout
EJB Deployment

• Use the same methods as for Web application


deployment:
– Auto-deployment
– Command-line deployment
Section Review

• In this section we learned how to:


– Recognize EJB Applications
– Deploy and Monitor EJBs
Lab Exercise

• Deploy an EJB
– Refer to the lab guide for more details.
– Ask the instructor for any clarification.
– The instructor will determine the stop time.
Roadmap

• 1. Web Applications
• 2. Enterprise JavaBeans (EJBs)
• 3. Enterprise Applications
– Enterprise Applications Concepts
– Enterprise Archive (EAR) File Structure
– Enterprise Application Configuration
– Enterprise Application Deployment
What is an Enterprise Application?

• An enterprise application is a grouping of


several resources into one deployable unit
packaged in an .ear file.
• These resources include:
– Web applications (.war)
– EJB applications (.jar)
– Java applications (.jar)
– Resource Adapter (.rar)
Why Use Enterprise Applications?

• Use enterprise applications:


– to avoid name space clashes
– if enterprise-wide security roles are needed to
– deploy an application as one unit enterprise-wide EJB
resources are needed
– Configure local JDBC Pools
EAR File Structure

• An example directory structure of an enterprise


application is shown below:
EAR Class Libraries

• When the application is initialized, extracted


paths are appended to the beginning of the
application’s CLASSPATH.
• Classes are added to the root classloader of the
application
Configure EAR

• Configure these enterprise-wide properties within the


application.xml deployment descriptor:
– Module type
– Security role definition
– Display name
• Configure these enterprise-wide features within the
jboss-application.xml deployment descriptor:
– Application-scoped JDBC connection pools
– Alternate deployment descriptor
– Security realms
– XML entity mappings
Deploying Enterprise Applications

• Use the same methods as for Web application


deployment:
– Auto-deployment
– Console deployment
– Command-line deployment
• Applications can be exploded in these formats:
– In an archived file (EAR)
– In exploded (open) directory format
Section Review

• In this section, we learned how to:


– Understand the structure of an enterprise
application
– Deploy an enterprise application
Lab Exercise

• Deploy an EAR
– Refer to the lab guide for more details.
– Ask the instructor for any clarification.
– The instructor will determine the stop time.

You might also like