JBoss installation
From Initq
We are going to install all the tools needed to run jboss and an example application. We will be installing
- Example Code
- Java
- Ant
- XDoclet
- JBoss
Before we start downloading the different components we need to set up our environment.
- Create an account called jbadmin.
- Set the password for jbadmin.
Contents |
The Example Code
We are going to install an application called Jaw Motors which is a fictitious automobile dealership. All Downloads
Installing Java
Main reason You need java is because all of JBoss is written in java so java is essential to running JBoss and your applications.
You will have java already installed by your distro but it is still good to install the full jdk and the correct version that jboss may desire. You need to make sure that you install JDK (Java 2 Development Kit) and not JRE (Java Run Time Environment). Also make sure that your version of java is higher than 1.4. You may download JDK from http://java.sun.com/javase/downloads/index.jsp.
If you want older version then please try http://java.sun.com/products/archive/.
Follow the instruction that sun gave you to install the JDK. After the installation we need to edit jbadmin's profile. Add the following lines to .bash_profile of jbadmin.
export JAVA_HOME=/usr/local/jdk1.6.0_10 PATH=$JAVA_HOME/bin export PATH
To test and see if everything is working, logout of jbadmin account and login again. Then do:
[jbadmin@ohnonono ~]$ java -version java version "1.6.0_10-rc2" Java(TM) SE Runtime Environment (build 1.6.0_10-rc2-b32) Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
Installing ANT
Ant is a build tool just like make for c or c++. ANT uses java classes and xml config files to compile and build packages.
You may download any from http://ant.apache.org/. Changes to .bash_profile for jbadmin user:
export ANT_HOME=/usr/local/apache-ant-1.7.1 PATH=$ANT_HOME/bin: export PATH
To test and see if ANT is working, logout of the jbadmin account and log back in. Then do:
[jbadmin@ohnonono ~]$ ant -version Apache Ant version 1.7.1 compiled on June 27 2008
XDoclet
We use XDoclet 1.2.3 to generate J2EE deployment descriptors, web.xml and various other J2EE configuration files for our application. XDoclet is a combination of custom Ant tasks and special attributes that you include in your source code. Please read the XDoclet Tutorial for more information.
Make sure to download the proper zip file and not the jar. What you need is xdoclet-bin-1.2.3.tgz. Unzip it and go into the sample directory. Make sure you get the bin package.
export XDOCLET_HOME=/opt/xdoclet-1.2.3 PATH=$PATH:$XDOCLET_HOME export PATH
To test your XDoclet installation, change to $XDOCLET_HOME/samples and run ant.
compile:
[echo] +---------------------------------------------------+
[echo] | |
[echo] | C O M P I L I N G S O U R C E S |
[echo] | |
[echo] +---------------------------------------------------+
[javac] /opt/xdoclet-1.2.3/samples/build.xml:605: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 109 source files to /opt/xdoclet-1.2.3/samples/target/classes
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
jar:
[echo] You can find the generated sources in the /samples/target/gen-src
[echo] directory and the compiled classes in the /samples/target/classes
[echo] directory. Enjoy!
BUILD SUCCESSFUL
Total time: 26 secondsJboss Installation
This is the easiest. Download jboss and unzip it. Go to the bin directory and create a file called run60.sh. Put the following in it:
#!/bin/bash /usr/bin/nohup /opt/jboss/jboss-6.0.0.20100216-M2/bin/run.sh -c default -Djboss.bind.address=0.0.0.0 -Djava.rmi.server.hostname=0.0.0.0 &
Now run the file. You can access jboss at http://<your ip>:8080. The default ip for the admin panel is admin/admin.
- bin/
- Start up and shutdown files.
- client/
- JAR files used by external client applications that remotely access (Java Naming and Directory Interface) JNDI resources.
- docs/
- jboss documentation is not found here.
- lib/
- JAR files that make up JBoss.
- server/
- Directories for the various server configurations.
Server Configuration
The server/ directory is the most important. This is where the JBoss services are located and the application deployed. There are three server sub-directories.
- minimal/
- Includes only JNDI and logging services.
- default/
- This runs if a server is not defined.
- all/
- This is the kitchen sink server configuration. This has clustering.
JBoss is nothing but a Java Management Extension microkernel. JMX is a framework that allows you to interact with live, running code. Services that implement JMX are called "managed beans" or MBeans. Log4j, tomcat, and Hibernate are all MBeans.
Let's look inside a default directory.
- conf/
- Includes configurations files for core services such as Log4j and JAAS. Main Server Configuration file is service.xml.
- deploy/
- Deployment directory for both dynamic JBoss services (MBeans) and your custom applications (EARs and WARs).
- lib/
- JAR files to support the dynamic JBoss services (MBeans).
Create a directory called default/undeploy. This is where you can move file when you want to shutdown services.
- data/ log/ tmp/ work/
- all these are temp directories. When JBoss is not running you may delete these directories.
Deploying JAW Motor
J2EE apps are normally bundled up as Enterprise Archive EAR or Web Archive WAR. JBoss services are bundled as SAR. Inside each application is nothing more than a Java Archive JAR.
Where to put files
- $JBOSS_HOME/lib
- application server's dependent libraries. Should always be JARs.
- $JBOSS_HOME/server/default/lib
- Server configuration's dependent libraries. Should always be JARs.
- $JBOSS_HOME/server/default/deply
- This is where your EAR, SAR and WAR files go.
Let's deploy first application from our jbossatwork download.
jbadmin@qrash:/opt/jaw/ch01/01a-test/webapp$ pwd /opt/jaw/ch01/01a-test/webapp jbadmin@qrash:/opt/jaw/ch01/01a-test/webapp$ ant Buildfile: /opt/jaw/ch01/01a-test/webapp/build.xml clean: [delete] Deleting directory /opt/jaw/ch01/01a-test/webapp/build compile: [mkdir] Created dir: /opt/jaw/ch01/01a-test/webapp/build [mkdir] Created dir: /opt/jaw/ch01/01a-test/webapp/build/classes war: [mkdir] Created dir: /opt/jaw/ch01/01a-test/webapp/build/distribution [war] Building war: /opt/jaw/ch01/01a-test/webapp/build/distribution/jaw.war all: BUILD SUCCESSFUL Total time: 1 second jbadmin@qrash:/opt/jaw/ch01/01a-test/webapp$ ls build build.xml web jbadmin@qrash:/opt/jaw/ch01/01a-test/webapp$ cd build/distribution/ jbadmin@qrash:/opt/jaw/ch01/01a-test/webapp/build/distribution$ ls jaw.war jbadmin@qrash:/opt/jaw/ch01/01a-test/webapp/build/distribution$ ls -la total 12 drwxr-xr-x 2 jbadmin jbadmin 4096 2010-05-08 23:50 . drwxr-xr-x 4 jbadmin jbadmin 4096 2010-05-08 23:50 .. -rw-r--r-- 1 jbadmin jbadmin 1422 2010-05-08 23:50 jaw.war jbadmin@qrash:/opt/jaw/ch01/01a-test/webapp/build/distribution$ cp -v jaw.war /opt/jboss/jboss-6.0.0.20100216-M2/server/default/deploy/ `jaw.war' -> `/opt/jboss/jboss-6.0.0.20100216-M2/server/default/deploy/jaw.war'
In your jboss console you should see
- 23:52:15,043 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/jaw
Now do you http://<ip>:8080/jaw