Here is step by step procedure to deploy a Simple JSP Web App on JBoss Application Server:
The steps are designed for Linux OS. For windows version please check here
1) Install Java
Obtain Java by clicking the "Download" button for Java SE Development Kit (JDK) 6 Update 14 at:
http://java.sun.com/javase/downloads/
Unzip the file into "~/java/" directory.
2) Install JBoss Application Server
Go to the JBoss download page at:
http://www.jboss.org/jbossas/downloads
Locate version 4.2.2.GA, and follow the "Download" link to get the "jboss-5.1.0.GA.zip" file.
Unzip the file into "~/java/" directory.
cd ~/java/
ls
jboss-4.2.2.GA jdk1.5.0_19
3) Create Work Folder in your personal projects directory
cd ~/projects
mkdir Helloworld
4) Create JBoss Startup Script: Just copy the below content into jboss file and make it executable.
#!/bin/bash
#
# Starts the jboss application server
# JAVA HOME
JAVA_HOME="/home/sheeju/java/jdk1.5.0_19/"
JBOSS_HOME="/home/sheeju/java/jboss-4.2.2.GA"
prog="jboss"
start() {
echo -n $"Starting $prog: "
$JBOSS_HOME/bin/run.sh
}
case "$1" in
start)
start
;;
*)
echo $"Usage: $0 {start}"
exit 1
esac
exit $?
This script will launch JBoss.
5) Write JSP File
Also in the "HelloWorld" folder, create a file named "index.jsp" as:
index.jsp
<html><head><title>JSP Test</title>
<%!
String message = "Hello, World.";
%>
</head>
<body>
<h2><%= message%></h2>
<%= new java.util.Date() %>
</body></html>
This JSP simply displays a greeting along with the current date and time.
6) Create Deployment Descriptor
In the "HelloWorld" folder, create a sub folder called "WEB-INF", and in that folder create a file named "web.xml" as:
web.xml
<web-app>
<display-name>Hello World</display-name>
</web-app>
The deployment descriptor provides information to JBoss about your web application.
8) Create WAR Builder & Deployer
In the "HelloWorld" folder, create a shell script named "deploy" as:
#!/bin/bash
#
# Starts the jboss application server
# JAVA HOME
JAVA_HOME="/home/sheeju/java/jdk1.5.0_19/"
JBOSS_HOME="/home/sheeju/java/jboss-4.2.2.GA"
prog="jboss"
start() {
echo -n $"Starting $prog: "
$JBOSS_HOME/bin/run.sh
}
case "$1" in
start)
PROJECT=$2
echo -n $"Deploying Project $PROJECT "
$JAVA_HOME/bin/jar -cvf $PROJECT.war *
cp $PROJECT.war $JBOSS_HOME/server/default/deploy/
;;
*)
echo $"Usage: $0 {start} {
exit 1
esac
exit $?
This script uses Java's JAR utility to zip up the appropriate contents into a WAR file.
9) execute deploy command
10) Test Your Web Page
In a browser, open "http://localhost:8080/HelloWorld/index.jsp" to see your web application run.
Now explore the JBoss console at "http://localhost:8080". Click on "JBoss Web Console" and expand "J2EE Domains", "jboss.management.local", and "JBoss". Select "helloworld.war" to see information about your web application.
No comments:
Post a Comment