Site hosted by Angelfire.com: Build your free website today!

Deploying an application on JBoss Server on RedHat Linux


For a small overview, JBoss is an open source J2EE application server, that was made to run on an open-source operating system, namely, Linux. It can also run on Windows, but why would you want to?
It can be installed as an RPM package in RedHat as easily as an executable can be in Windows. JBoss ties into the MYSQL database server nicely, which also comes with RedHat, and is of course, open source. Now just add the free Java Development Kit and the free, open source build tool ANT from Jakarta, and you're left with the lowest cost best performing ebusiness solution available.

Redhat Linux comes with the JDK already installed on it, but you should download that anyway. Depending on what version of RedHat you are using, it alos comes with MYSQL as well. I am using RedHat 8.0 for my applications.


Setup/Installation
Download JBoss/Tomcat Application/Web Servers from www.jboss.org

Download and install MYSQL from home.ubalt.edu/abento/452/mysql/

Download the ANT build tool from www.jakarata-apache.org

As long as we're talking about Jakarata, we might as well download the open-source Struts framwork as well. If you're not familiar with Struts, it is an open-source Java framework for implementing a Model-View-Controller model thru the use of a Controller Servlet, XML config files, and JSPs. Struts seemlessly integrates into virtually any Java ebusiness solution.

MYSQL Configuration
After MYSQL has been installed, there are just a few steps required to ties into JBoss and you've got a fully functional free database to use:
First we need to copy the mysql-2.0.11.jar drive to server\default\lib
Also copy mysql-service.xml to server\default\deploy

Now we need to modify mysql-service.xml properties to reflect the MySqlDb.

Need to modify server\default\conf\login-config.xml to add authentication.

Need to make MySQL the default database JBoss uses by modifying the server\default\conf\standardjbosscmp-jdbc.xml and standardjaws.xml files.
Need to to change the datasource and datasource-mapping to MySqlDb and mySQL respectively.
Also, before an application can be run, the database should be setup as a service to ensure it is always available when JBoss needs it. If not, go to /usr/bin before you start JBoss and start the MYSQL server by using ./safe_mysqld.

Environment Configuration
JBoss should usually be run as root, so we need to setup the shell environment with the appropriate variables. This can be done in the .bashrc or .cshrc file, like this:
#! /bin/csh
setenv JAVA_HOME /usr/java/jdk1.3.1_05
setenv ANT_HOME /usr/local/jakarta-ant-1.3
setenv JBOSS_HOME /usr/local/jboss-3.0.3_tomcat-4.0.5
#setenv PATH /usr/java/jdk1.3.1_05/bin:/usr/local/sbin:/usr/local/jakarta-ant-1.3/bin:/usr/sbin:/sbin:${PATH}:${HOME}/bin
setenv PATH /usr/local/jakarta-ant-1.3/bin
setenv CLASSPATH /usr/local/jboss-3.0.3_tomcat-4.0.5/bin/run.jar:/lib/tools.jar:/usr/local/jboss-3.0.3_tomcat-4.0.4/lib/src.jar


Next, your JBoss installation/directory structure should look like this:
JBoss startup directory: $JBOSS_HOME/bin
JBoss deploy directory:  $JBOSS_HOME/server/default/deploy
JBoss config directory:  $JBOSS_HOME/server/default/conf
JBoss lib directory:       $JBOSS_HOME/server/default/lib

Before we can start JBoss, we just need to make sure that the environment and run scripts for JBoss are setup correctly. In the /usr/local/JBOSS_HOME/bin directory, make sure the setenv.sh and run.sh scripts have their PATH and CLASSPATH variables set to reference anything JBoss needs to deploy on startup, such as the Java, Tomcat, MySQL, etc... Once that is done, you can simply type in ./run.sh in the bin directory and JBoss will start. This also enables the Tomcat webserver, which is a part of JBoss.
The Tomcat webserver will be running on port 8080 by default, so a typical URL would be http://localhost:8080.

Deploying in JBoss
When deploying an application on JBoss, it is very similar to other application server in the way that your packaged application will be deployed from within a JBoss directory. So, when you are using ANT to build and package your application code, make sure that your application ends up in the $JBOSS_HOME/server/default/deploy directory, and is of course package correctly according to the J2EE application standards. This package structure is very common and does not need to be altered at all when deploying on different application servers.