Deploying Applications

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Deploying Applications as PDF for free.

More details

  • Words: 1,663
  • Pages: 27
Professional Open Source™

Deploying Applications ”Make EAR, not WAR.”

© JBoss, Inc. 2003-2005.

October 14, 2008

1

Topics and Objectives Professional Open Source™

 In this section we will cover: – Different application packages that exist in J2EE and JBoss – Hot- and redeploy of applications and services – Expanded deployments (no archive packages) – In the end, hands-on exercise on deploying applications on JBoss

© JBoss, Inc. 2003-2005

2

J2EE Application Packaging Professional Open Source™

 J2EE defines packaging structure for middleware applications – Essentially these are all ZIP archives – Use your favorite tools to manipulate them: • jar, zip, etc. from command line • WinZip, Windows Explorer, etc. from a GUI – Packages usually contain • Java class files developers produce • Package configuration file – deployment descriptor • Resource files for the application – Configuration files, image files, HTML files, XML files, etc.

© JBoss, Inc. 2003-2005

3

J2EE Application Packaging Professional Open Source™

 In JBoss you will find these basic package types: – Web Archive (*.war) • For web applications (Servlets and Java Server Pages on Tomcat) – EJB Archive (*.jar) • Enterprise JavaBean components – Enterprise Application Archive (*.ear) • Collects Web Archives and EJB Archives into a single deployable unit – Resource Adapter Archives (*.rar) • Connectors from application server to enterprise information systems (EIS): RDBMS, SAP/R3, CICS, etc. – Web Service Archives (*.wsr) • Components accessible via SOAP and other web service protocols – JBoss Service Archive (*.sar) • Service implementations deployed on JBoss microkernel

© JBoss, Inc. 2003-2005

4

J2EE Application Packaging Professional Open Source™

 Example: Web Archive (*.war) – Contains web tier applications • Servlet/JSP implementations • Related resource files for HTTP output • Deployment descriptors: web.xml and jboss-web.xml

© JBoss, Inc. 2003-2005

5

JBoss Deployment Professional Open Source™

 How to deploy HelloAdmin.war ? – Locate ”deploy” directory in your server configuration – Choose the ”deploy” directory of your server configuration HelloAdmin.war

run –c MyConfig vs. run –c default

– Use GUI tools (e.g. Explorer) to drag and drop the application package to your ”deploy” directory – Or use command line tools > mv HelloAdmin.war server/MyConfig/deploy 

© JBoss, Inc. 2003-2005

You can deploy packages on a live server. This is what we call hot-deployment.

6

JBoss Deployment Professional Open Source™

 When you drop the HelloAdmin.war file to deploy directory – It is picked up by a DeploymentScanner service • Configured in conf/jboss-service.xml • You can change: – Scanning interval – Directories that are scanned (URLs)

– You’ll notice in the server console that the deployment is picked up • Or in the log/server.log with much more detail

© JBoss, Inc. 2003-2005

21:51:08,477 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080 21:51:08,707 INFO [ChannelSocket] JK2: ajp13 listening on /0.0.0.0:8009 21:51:08,717 INFO [JkMain] Jk running ID=0 time=0/110 config=null 21:51:08,727 INFO [Server] JBoss (MX MicroKernel) [4.0.1sp1 (build: CVSTag=JBoss_4_0_1_SP1 date=200502160314)] Started in 47s:358ms 21:53:34,397 INFO [TomcatDeployer] deploy, ctxPath=/HelloAdmin, warUrl=file:/C:/Programs/JBoss/server/MyConfig/deploy/

7

JBoss Deployment Professional Open Source™

 What you can read from this line: 21:53:34,397 INFO [TomcatDeployer] deploy, ctxPath=/HelloAdmin, warUrl=file:/C:/Programs/JBoss/server/MyConfig/dep loy/HelloAdmin.war/

– A web application archive (WAR) was succesfully installed. – Context path of the web application is /HelloAdmin • You can verify it by using your browser to connect to http://localhost:8080/HelloAdmin – Defaults to package name: HelloAdmin.war  /HelloAdmin – HTTP connector runs at port 8080 by default

– The location of the file that was deployed You can find a lot more detail (DEBUG level) about this deployment in server//log/server.log. This is especially useful in case of failed deployments.

© JBoss, Inc. 2003-2005

8

JBoss Deployment Professional Open Source™



You can also try and locate your deployed package from the web-console: – http://localhost:8080/web-console

© JBoss, Inc. 2003-2005

9

JBoss Undeployment And Redeployment Professional Open Source™

 How to undeploy a service or application: – Delete package from deploy directory 00:44:38,135 INFO [TomcatDeployer] undeploy, ctxPath=/HelloAdmin, warUrl=file:/C:/Programs/JBoss/server/MyConfig/deploy/H elloAdmin.war

 How to redeploy a service or application: – Change the timestamp of the deploy package (e.g. touch) – Causes an undeploy – deploy sequence 00:52:23,605 INFO [TomcatDeployer] undeploy, ctxPath=/HelloAdmin, warUrl=file:/C:/Programs/JBoss/server/MyConfig/deploy/HelloAdmin.war 00:52:23,695 INFO [TomcatDeployer] deploy, ctxPath=/HelloAdmin, warUrl=file:/C:/Programs/JBoss/server/MyConfig/deploy/HelloAdmin.war

© JBoss, Inc. 2003-2005

10

Professional Open Source™

Other Deployment Options ”On the road to Timbuktu.”

© JBoss, Inc. 2003-2005.

October 14, 2008

11

Expanded Deployments Professional Open Source™



Services and applications can be deployed as directories – Previous examples used ZIP archives (*.war, *.jar, *.ear, *.sar, etc.) – Zip archives are easy to distribute but sometimes unpleasant to manage • When making configuration changes you must: 1. 2. 3. 4. 5.



Undeploy Extract Modify Re-zip Deploy

All packages can be deployed as expanded directories instead – Allows for direct file modification on a deployed package

© JBoss, Inc. 2003-2005

12

Expanded Deployments Professional Open Source™

 How to deploy a directory package – Simply create a directory with a proper extension and follow the zip archive structure inside the directory

Instead of deploying this...

Deploy this.

HelloAdmin.war

© JBoss, Inc. 2003-2005

13

Expanded Deployments Professional Open Source™

 How to undeploy directory package – Same as zip package  Delete the directory

 How to redeploy directory package – Change the timestamp on the deployment descriptor Note – changing the timestamp on the directory itself will not work.

 Deployment descriptors for different package types: EJB JAR: EAR:

META-INF/ejb-jar.xml META-INF/application.xml

WAR: SAR:

WEB-INF/web.xml META-INF/jboss-service.xml

Note – the descriptor paths are case sensitive.

© JBoss, Inc. 2003-2005

14

Expanded Deployments Professional Open Source™

 Example: – Changing the context root of a deployed servlet – Locate the WEB-INF/jboss-web.xml deployment descriptor: <jboss-web> /AdminApplication

– Touch the web.xml file (timestamp changes) • existing web application at http://localhost:8080/HelloAdmin will undeploy and redeploy at http://localhost:8080/AdminApplication.

© JBoss, Inc. 2003-2005

15

Nested Deployment Professional Open Source™

 You can nest service and application packages – When packages are deployed they are searched recursively for sub-packages – Nested expanded deployments are also supported – Redeployment and undeployment only work on the top level package • You must manage the entire tree as one deployment • You can’t redeploy or undeploy individual sub-packages

© JBoss, Inc. 2003-2005

16

Default JBoss Web Application Professional Open Source™

 How to change the default JBoss page? – Tomcat servlet container is embedded inside JBoss server – It is located under deploy/jbosswebtomcat50.sar – Under that directory there’s a special web archive, ROOT.war

– Simply modify this archive to become your default web application • Or remove completely • Or use root (’/’) as the context root of an existing application

© JBoss, Inc. 2003-2005

17

Configuration File Deployment Professional Open Source™

 What are the service.xml files in the deploy directory? – You notice in ”deploy” directory there are several XML files that follow the naming convention -service.xml – These are deployment descriptors deployed without associated Java class libraries – Sometimes it makes sense to deploy just a new instance of an existing service • No need to package classes • Easy modification • Deployment/undeployment works the same as with full service packages • -service.xml is the equivalent of jboss-service.xml in a SAR package

© JBoss, Inc. 2003-2005

18

Conclusion Professional Open Source™

– JBoss has dynamic deployment for ease-of-use • Simple add/remove of files • Can be done on a live server instance – Service and application packages are ZIP files • Contain deployment descriptors specific to each package type • SAR, EAR, WAR, RAR, WSR, JAR – Deployment is possible with expanded directories – Redeployment is triggered by touching the deployment descriptor

© JBoss, Inc. 2003-2005

19

Test Professional Open Source™

– Touching jboss-service.xml redeploys a service implementation (T/F) ? – Touching jboss-web.xml redeploys web application (T/F) ? – Changing a web application’s URL path requires a restart (T/F) ? – Tomcat deploys *.tar archives from ROOT.war directory (T/F) ? – Deleting a package from deploy directory uninstalls it (T/F) ? – JBoss supports hot-deployment of all package types (T/F) ? – J2EE packages require a proprietary deployment tool to modify (T/F) ?

© JBoss, Inc. 2003-2005

20

Lab Deployment Professional Open Source™

 LAB-DEPLOYMENT

© JBoss, Inc. 2003-2005

21

Lab Deployment Professional Open Source™

An Hello World Service This is a simple example of a JBoss Service. It lets you Configure a message, which it prints out at start/stop. There is also a printMessage() operation and the message is configurable as an attribute. The Management Interface The key things are to extend ServiceMBean and define our management interface. package com.acme; import org.jboss.system.ServiceMBean; public interface HelloWorldServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute String getMessage(); void setMessage(String message);

} © JBoss, Inc. 2003-2005

// The print message operation void printMessage();

22

Lab Deployment Professional Open Source™

The Service Implementation

Now we have to implement our management interface and the start/stop  example lifecyle. We must implement our management according to  the jmx spec and we extend ServiceMBeanSupport to do the  heavy lifting.  package com.acme; import org.jboss.system.ServiceMBeanSupport; public class HelloWorldService extends ServiceMBeanSupport implements HelloWorldServiceMBean { // Our message attribute private String message = "Sorry no message today";

© JBoss, Inc. 2003-2005

23

Lab Deployment Professional Open Source™

// The lifecycle protected void startService() throws Exception { log.info("Starting with message=" + message); } protected void stopService() throws Exception { log.info("Stopping with message=" + message); } }

© JBoss, Inc. 2003-2005

24

Lab Deployment Professional Open Source™

The deployment descriptor (jboss­service.xml) <server> <mbean code="com.acme.HelloWorldService" name="acme.com:service=HelloWorld"> Hello World

© JBoss, Inc. 2003-2005

25

Lab Deployment Professional Open Source™

Now create a SAR for your service This is a jar file or directory (called hello­world.sar in this  example) with the following structure:  hello-world.sar hello-world.sar/META-INF/jboss-service.xml hello-world.sar/com/acme/HelloWorldService.class hello-world.sar/com/acme/HelloWorldServiceMBean.class

© JBoss, Inc. 2003-2005

26

Lab Deployment Professional Open Source™

// Getters and Setters public String getMessage() { return message; } public void setMessage(String message) { this.message = message; }

}

// The print message operation void printMessage();

// The printMessage operation public void printMessage() { log.info(message); }

© JBoss, Inc. 2003-2005

27

Related Documents

Deploying Applications
November 2019 19
Deploying Ias
November 2019 12
Deploying Wins
November 2019 19
Deploying Dhcp
November 2019 9
Applications
November 2019 28
Applications
November 2019 23