Jboss
JBoss is an open source EJB container. The most recent version of JBoss is 2.1 which can be downloaded
from http://www.jboss.org/business/binary.html.
1. Download JBoss-2.1.zip. We do not require an integrated JBoss-Tomcat.zip because we will already be
having Tomcat installed on our system (as per point VI). There are no separate files for Windows or Linux
operating systems. The same binaries will run on both the platforms. JBoss will run with both Java 1.2.2 and
Java 1.3. But it is better if you run it with Java 1.3.
2. Create a directory called jboss2.1. The command for Linux is:
# mkdir /usr/local/jboss2.1
3. Copy the JBoss-2.1.zip file in /usr/local/jboss2.1 directory.
4. Decompress the JBoss-2.1.zip. It will create a directory with name dist in /usr/local/jboss2.1 directory.
Command is :
# unzip JBoss-2.1.zip
5. Before running the JBoss server , you should check that your JDK installation is working. You will need the
JDK binaries directory in you PATH.
6. For running the JBoss server, go to the /usr/local/jboss2.1/dist/bin directory and type the following command:
# java -jar run.jar.
This will start the JBoss server using the default configurations in /usr/local/jboss2.1/dist/conf/default directory.
IX. Running JBoss with Tomcat
JBoss is just an EJB container. It is not a Servlet/JSP container. So if you want your Enterprise bean to be
accessed from a servlet/Java server page you need a servlet container such as Tomcat. But in that case
the Servlet container will not run in the same memory (or say same JVM) as the EJB container is running.
So we have to run both the Containers in same JVM. This can be done by using the feature of Embedded
Tomcat through which you can configure your JBoss and Tomcat to make them run in a single VM. The
JSP/Servlet engine talks natively with the EJB engine resulting in dramatic speed increases.
For running Tomcat in the same VM with JBoss you have to make changes in configuration files of both
tomcat and JBoss. Step by Step configuration changes are as follows:
1. Edit jboss.conf file to add tomcat libs to server classpath.
Open /usr/local/jboss2.1/dist/conf/default/jboss.conf file and make following change:
<!-- Uncomment to add Tomcat classes to classpath
-- MLET CODE = "org.jboss.util.ClassPathExtension" ARCHIVE="jboss.jar"
CODEBASE="../../lib/ext/">
-- ARG TYPE="java.lang.String" VALUE="path to tomcat lib directory">
-- ARG TYPE="java.lang.String" VALUE="Tomcat">
-- /MLET>
-->
In jboss.conf, uncomment the above code to add tomcat libraries to server classpath.
In the value for first <ARG TYPE> give the path of tomcat lib directory. For eg: if
you have installed tomcat in /usr/local/tomcat, then give /usr/local/tomcat/lib/ in the
value. Dont forget to give trailing slash(/) after lib. So after changes this MLET tag
should look like as follows:
<MLET CODE = "org.jboss.util.ClassPathExtension" ARCHIVE="jboss.jar"
CODEBASE="../../lib/ext/">
<ARG TYPE="java.lang.String" VALUE="/usr/local/tomcat/lib/">
<ARG TYPE="java.lang.String" VALUE="Tomcat">
</MLET>
2. Edit JBoss.jcml
In JBOSS_HOME/conf/default/ edit the jboss.jcml file to uncomment the EmbeddedTomcat
Service mbean.
<!--
Uncomment to add embedded tomcat service
<mbean code="org.jboss.tomcat.EmbeddedTomcatService"
name="DefaultDomain:service=EmbeddedTomcat" />
-->
and uncomment the mbean line so it reads as follows:
<!-- Uncomment to add embedded tomcat service -->
<mbean code="org.jboss.tomcat.EmbeddedTomcatService" name="DefaultDomain:service=EmbeddedTomcat" />
Further down in the jboss.jcml file, make sure your J2eeDeployer is set as:
<mbean code="org.jboss.deployment.J2eeDeployer" name="J2EE:service=J2eeDeployer">
<attribute name="DeployerName">Default</attribute>
<attribute name="JarDeployerName">:service=ContainerFactory</attribute>
<attribute name="WarDeployerName">:service=EmbeddedTomcat</attribute>
<mbean>
3. Edit Tomcat's server.xml
Add the following lines to server.xml in TOMCAT_HOME/conf/
<!-- JBoss, Setup the class loader heirarchy to enable in VM call optimization.
Add after the org.apache.tomcat.context.WorkDirInterceptor ContextInterceptor -->
<ContextInterceptor className="org.jboss.tomcat.ContextClassLoaderInterceptor" />
<!-- JBoss, Add the jboss-web.xml parser. Add after the org.jboss.tomcat.ContextClassLoaderInterceptor
ContextInterceptor -->
<ContextInterceptor className="org.jboss.tomcat.naming.JbossWebXmlReader" />
<!-- JBoss, Set the request thread classloader. Add before the org.apache.tomcat.request.SessionInterceptor
RequestInterceptor -->
<RequestInterceptor className="org.apache.tomcat.request.Jdk12Interceptor" />
<!-- JBoss, Map the current web user to the SecurityAssociation principal. Add
after the org.apache.tomcat.request.SimpleRealm RequestInterceptor -->
<RequestInterceptor className="org.jboss.tomcat.security.JbossRealm" />
4. Adding javac to the server classpath
If you are going to be using JSP files with tomcat, you need to add the JDK lib/tools.jar file to the classpath to pickup the javac compiler. You can do this by either setting your CLASSPATH env variable, by editing run.sh/run.bat to add tools.jar to CLASSPATH, or by copying tools.jar to the TOMCAT_HOME/lib directory.
5. Start JBoss
If you start JBoss now by typing java -jar run.jar from /usr/local/jboss2.1/dist/bin directory, you should see the following Tomcat related output in your log messages:
Using configuration "default"
[Info] Java version: 1.3.0_01,Sun Microsystems Inc.
[Info] Java VM: Java HotSpot(TM) Server VM 1.3.0_01,Sun Microsystems Inc.
[Info] System: Linux 2.2.16-22,i386
...
[EmbeddedTomcat] Starting
[EmbeddedTomcat] Starting EmbeddedTomcat....
2001-02-20 05:01:23 - ContextManager: Adding context Ctx( /examples )
2001-02-20 05:01:23 - ContextManager: Adding context Ctx( /admin )
[EmbeddedTomcat] Starting tomcat. Check logs/tomcat.log for error messages
2001-02-20 05:01:23 - ContextManager: Adding context Ctx( )
2001-02-20 05:01:23 - ContextManager: Adding context Ctx( /test )
2001-02-20 05:01:25 - PoolTcpConnector: Starting HttpConnectionHandler on 8080
2001-02-20 05:01:25 - PoolTcpConnector: Starting Ajp12ConnectionHandler on 8007
[EmbeddedTomcat] OK
[EmbeddedTomcat] Started
...
[Default] JBoss PRE-2.1 Started in 0m:14s