Skip to main content

Setting a lightweight JBoss server for web development only

Posted by felipeal on October 27, 2004 at 9:04 PM PDT

A couple of months ago, I had to implement a custom LoginModule to be used by a J2EE application running primarily on JBoss 3.0.8 (bundled with Tomcat 4.1.24). While developing it, I had to restart JBoss on every new progress, in order to test the changes. As my desktop was just a poor Pentium III with 512MB, running all sort of geek stuff (mozilla, emacs, eclipse, many shells, gaim, openoffice, etc...), JBoss started in about 2 minutes and stopped in another 1:30 minutes, totalizing long 4 minutes for every iteration!

So, as a good 'lazy developer', I decided to spend some time cleaning JBoss (I was using the default configuration, which loads a lot of stuff that didn't matter to my LoginModule, such as EJB container, Messaging server, EAR deployet, HSQLDB, etc...) and recover that time during each iteration. So here's what I did:

1.Started copying the minimal server configuration to a new configuration called web:

cp -a ${JBOSS_HOME}/server/minimal ${JBOSS_HOME}/server/web

2.Copied the tomcat41-service.xml from the default configuration:

cp ${JBOSS_HOME}/server/default/deploy/tomcat41-service.xml ${JBOSS_HOME}/server/web/deploy

3.Copied some JARs from default's lib:

cd ${JBOSS_HOME}/server/default/lib; cp jboss.jar tomcat41-service.jar jbosssx.jar ../../web/lib

At this point, the new server was already ready for web development, and starting as a breeze:

~felipeal# ${JBOSS_HOME}/bin/ -c web



00:25:43,280 INFO  [Server] JBoss (MX MicroKernel) [3.0.8 (CVSTag=JBoss_3_0_8 Date=200306050849)] Started in 0m:7s:303ms

Now I needed to set the authentication stuff:

4.Added new MBeans on jboss-service.xml:

<mbean code=""
    <attribute name="LoginConfig"></attribute>
  <mbean code=""
    <attribute name="ConfigResource">login-config.xml</attribute>

  <mbean code=""
    <attribute name="SecurityManagerClassName">

5.Created the login-config.xml on web/conf, adding my custom LoginModule:

<?xml version='1.0'?>
      "-//JBoss//DTD JBOSS Security Config 3.0//EN"

<!-- put my login module setup here - don't remember the details :-) -->

6.(optional) If running on JDK 1.3, it's also necessary to copy jboss-jaas.jar and xalan.jar to lib:

cd ${JBOSS_HOME}/server/default/lib; cp jboss-jaas.jar xalan.jar jbosssx.jar ../../web/lib

That's it: the new server was ready for quick development cycles (startup and shutdown in about 20s!)

Now, back to present day, I had to configure JBoss 3.2.5 to run as a web-server only (I know I could use a pristine Tomcat 5.0.x, but it had to be JBoss) on my home server, which is also an old PIII, again running a lot of stuff (xinetd, mysql, tomcat, X, eclipse, emacs, gaim, evolution, mozilla, etc...).

The steps changed a little bit, but fortunately not that much:

1.Start copying the minimal configuration:

cp -a ${JBOSS_HOME}/server/minimal ${JBOSS_HOME}/server/web

2.Instead of copying tomcat4-service.xml, copy the whole jbossweb-tomcat50.sar directory:

cp -a ${JBOSS_HOME}/server/default/deploy/jbossweb-tomcat50.sar ${JBOSS_HOME}/server/web/deploy

3.Copy some JARs from default's lib:

cd ${JBOSS_HOME}/server/default/lib; cp jboss.jar jboss-j2ee.jar jbosssx.jar ../../web/lib

4.Assuming you don't need transactions neither Tomcat's CachedConnectionValve, comment out the following lines on ${JBOSS_HOME}/server/web/deploy/jbossweb-tomcat50.sar/META-INF/jboss-service.xml:


That's it, now you have a 'clean' JBoss 3.2.5 web server ready to roll! Note that this new server is not that faster proportionally (in my case, the startup is 30s against 1m from the default configuration), but it still saves you a good ammount of resources (memory, threads, file handlers, etc...).

Related Topics >>