View RSS Feed

My Java Tips

Deploying WAR on JBOSS

Rate this Entry
by , 11-04-2011 at 07:52 PM (4461 Views)
I will present simple steps to create a web application (WAR) and will show how to deploy a WAR on JBOSS.


Let me start from installing Java.
http://java.sun.com/javase/downloads/

Run the installer and install Java at: "C:\Program Files\Java\jdk1.6.0_06\". An important thing to note is that JBoss, requires the full JDK which contains the JRE along with some additional stuff like javac compiler.

Next step is to install JBoss. Go to the JBoss download page at:
http://labs.jboss.org/jbossas/downloads

Download and install the version you like. I am using JBoss version 4.2.2.GA.

Next step is to create a work folder. Create is separately lets say: C:\Projects\HelloWorld. In the work folder, create a file named "JBoss.bat" and add following contents:


@echo off
set JAVA_HOME=Program FilesJavajdk1.6.0_06
set JBossHome=AppsJBossjboss-4.2.2.GA
set Path=%JAVA_HOME%bin;%Path%
cd "%JBossHome%bin"
run.bat

This script will simply launch JBoss application server.



Now create a JSP file in the work folder.


Java Code:
<%!
String msg = "Hello World.";
%>


<%= msg %>


<%= new java.util.Date() %>
Now is the time to create deployment descriptor. The deployment descriptor is used to provide information to JBoss about our web application.

In your work folder (HelloWorld folder), create a sub folder called WEB-INF. Create a file named web.xml in it with following contents:

Hello World

This is the last part of Deploying WAR on JBOSS.




Create a file called "Deploy.bat" in the work folder and add following script:


@echo off
set JAVA_HOME=Program FilesJavajdk1.6.0_06
set JBossHome=AppsJBossjboss-4.2.2.GA
"%JAVA_HOME%binjar.exe" -cvf helloworld.war *.jsp WEB-INF
copy helloworld.war "%JBossHome%serverdefaultdeploy"
pause

We used Java's JAR utility to zip up the appropriate contents into a WAR file and copied the WAR file on to the deploy folder of default configuration.

Its done now. Run JBoss using JBoss.bat and then deploy your application by running Deploy.bat.

Time to test the application. Open "http://localhost:8080/helloworld/hi.jsp" to see your web application run.

Submit "Deploying WAR on JBOSS" to Facebook Submit "Deploying WAR on JBOSS" to Digg Submit "Deploying WAR on JBOSS" to del.icio.us Submit "Deploying WAR on JBOSS" to StumbleUpon Submit "Deploying WAR on JBOSS" to Google

Tags: None Add / Edit Tags
Categories
Java EE , JBoss

Comments