The Source for Java Technology Collaboration
User: Password:



Felipe Leme's Blog

October 2004 Archives


Setting a lightweight JBoss server for web development only

Posted by felipeal on October 27, 2004 at 09:04 PM | Permalink | Comments (11)

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/run.sh -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="org.jboss.security.plugins.SecurityConfig"
	 name="jboss.security:name=SecurityConfig">
    <attribute name="LoginConfig">jboss.security:service=XMLLoginConfig</attribute>
  </mbean>
  <mbean code="org.jboss.security.auth.login.XMLLoginConfig"
	 name="jboss.security:service=XMLLoginConfig">
    <attribute name="ConfigResource">login-config.xml</attribute>

  </mbean>
  <mbean code="org.jboss.security.plugins.JaasSecurityManagerService"
	 name="jboss.security:service=JaasSecurityManager">
    <attribute name="SecurityManagerClassName">
      org.jboss.security.plugins.JaasSecurityManager
    </attribute>
  </mbean>


5.Created the login-config.xml on web/conf, adding my custom LoginModule:
<?xml version='1.0'?>
<!DOCTYPE policy PUBLIC
      "-//JBoss//DTD JBOSS Security Config 3.0//EN"
      "http://www.jboss.org/j2ee/dtd/security_config.dtd">

<policy>
<!-- put my login module setup here - don't remember the details :-) -->
</policy>
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!)


Continue Reading...





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds