HowToAddAprToJBoss

How to Add the Apache Portable Runtime (APR) to JBoss

JBoss 4.2

 

Out-of-the-box, JBoss AS 4.2 is a 100% pure Java application server, and embeds Tomcat 6 as its servlet container.

 

By default, it will use java to handle HTTP connections.  With a few simple steps (outlined below),

 

you can add the Apache Portable Runtime (APR) to achieve native HTTP processing performance.

 

Note: The instructions below have been tested on:

  • JBoss AS 4.2.0.GA on Fedora Core 6 (Linux 2.6.20-1.2952.fc6) using Sun JDK 1.5.0_11

  • JBoss AS 4.2.0.GA on Windows XP Pro SP2 using Sun JDK 1.6.0_01

 

1-6 are the without APR steps, and 7-12 are the with APR steps, to give you a complete "before and after" picture.

 

The instructions below assume Linux; instructions for Windows mirror these.

 

1. Download JBoss AS 4.2.0.GA from: http://labs.jboss.com/jbossas/download

 

 

2. Extract JBoss AS

$ unzip jboss-4.2.0.GA.zip

 

3. Notice the files included in the bin subdirectory out-of-the-box.

$ cd jboss-4.2.0.GA/bin
$ find . -type f | sort
./classpath.sh
./jboss_init_hpux.sh
./jboss_init_redhat.sh
./jboss_init_suse.sh
./probe.bat
./probe.sh
./run.bat
./run.conf
./run.jar
./run.sh
./shutdown.bat
./shutdown.jar
./shutdown.sh
./twiddle.bat
./twiddle.jar
./twiddle.sh
./wsconsume.bat
./wsconsume.sh
./wsprovide.bat
./wsprovide.sh
./wsrunclient.bat
./wsrunclient.sh
./wstools.bat
./wstools.sh

 

4. Run JBoss AS

$ ./run.sh

 

5. Notice certain console output that indicates no APR presence

 

(Note the output of the AprLifecycleListener)

...
17:33:23,852 INFO  [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/jdk1.5.0_11/jre/lib/i386/server:/usr/java/jdk1.5.0_11/jre/lib/i386:/usr/java/jdk1.5.0_11/jre/../lib/i386
17:33:23,973 INFO  [Http11Protocol] Initializing Coyote HTTP/1.1 on http-127.0.0.1-8080
17:33:23,974 INFO  [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-127.0.0.1-8009
...
17:33:30,162 INFO  [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
17:33:30,181 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
17:33:30,202 INFO  [Server] JBoss (MX MicroKernel) [4.2.0.GA (build: SVNTag=JBoss_4_2_0_GA date=200705111440)] Started in 17s:669ms

 

6. Stop JBoss AS

<ctrl-c>

 

7. Download JBoss Native (part of the JBoss Web project) from: http://www.jboss.org/jbossweb/downloads/jboss-native/

 

It is very important that you choose the right native-built libraries for your operating system.

 

8. Extract JBoss Native into the bin directory of JBoss AS

$ tar xzvCf jboss-4.2.0.GA jboss-native-2.0.0-linux2-i686.tar.gz

 

9. Notice the new files that are now included in the bin subdirectory (native/, openssl)

$ cd jboss-4.2.0.GA/bin
$ find . -type f | sort
./classpath.sh
./jboss_init_hpux.sh
./jboss_init_redhat.sh
./jboss_init_suse.sh
./native/engines/lib4758cca.so
./native/engines/libaep.so
./native/engines/libatalla.so
./native/engines/libchil.so
./native/engines/libcswift.so
./native/engines/libgmp.so
./native/engines/libnuron.so
./native/engines/libsureware.so
./native/engines/libubsec.so
./native/libapr-1.so.0.2.8
./native/libcrypto.so.0.9.8
./native/libssl.so.0.9.8
./native/libtcnative-1.so.0.1.11
./openssl
./probe.bat
./probe.sh
./run.bat
./run.conf
./run.jar
./run.sh
./shutdown.bat
./shutdown.jar
./shutdown.sh
./twiddle.bat
./twiddle.jar
./twiddle.sh
./wsconsume.bat
./wsconsume.sh
./wsprovide.bat
./wsprovide.sh
./wsrunclient.bat
./wsrunclient.sh
./wstools.bat
./wstools.sh

 

Please note that the tar files may be bundled in different directories. In this case you will need to move them to their appropriate directories.

 

For e.g., do this for JBoss Native 2.0.4 Linux x86

lib/linux2/x86/*.so --> $JBOSS_HOME/bin/native
lib/linux2/x86/engines/*.so --> $JBOSS_HOME/bin/native/engines
bin/linux2/x86/openssl --> $JBOSS_HOME/bin

 

10. Re-run JBoss AS, which will now detect the presence of the native libraries and leverage them

$ ./run.sh

 

11. Notice certain console output that indicates the presense of the APR

 

(Note the output of the AprLifecycleListener, as well as the usage of the Http11AprProtocol and AjpAprProtocol, not Http11Protocol and AjpProtocol.)

...
17:35:39,240 INFO  [AprLifecycleListener] Loaded Apache Tomcat Native library 1.1.11.
17:35:39,241 INFO  [AprLifecycleListener] APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
17:35:39,511 INFO  [Http11AprProtocol] Initializing Coyote HTTP/1.1 on http-127.0.0.1-8080
17:35:39,512 INFO  [AjpAprProtocol] Initializing Coyote AJP/1.3 on ajp-127.0.0.1-8009
...
17:35:44,525 INFO  [Http11AprProtocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
17:35:44,544 INFO  [AjpAprProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
17:35:44,566 INFO  [Server] JBoss (MX MicroKernel) [4.2.0.GA (build: SVNTag=JBoss_4_2_0_GA date=200705111440)] Started in 15s:462ms

 

Success!

 

12. Stop JBoss AS

<ctrl-c>

 

13. Debugging:

In case it is not working edit the jboss-log4j.xml corresponding to your configuration add

  <category name="org.apache.catalina.core">
      <priority value="DEBUG"/>
  </category>

Restart JBoss AS and look in server.log file and look for the exception near org.apache.catalina.core.AprLifecycleListener.

 


Notes for FreeBSD:

 

 

  • extract the archive, edit  and set  at the beginning of the file ( FreeBSD's  doesn't recognize the options  and )

 

  • set the environment variable  to your diablo jdk, usually

 

  (This env var is just needed for the build. diablo jdk uses  for normal operations)

 

  • run  (normally all the required libraries should be found, since FreeBSD uses a file system layout according to FHS)

 

 

My FreeBSD System is a FreeBSD 6.2-RELEASE. At least for me it works.

 

Variant 2 for FreeBSD using ports:

 

  • cd /usr/ports/java/jboss4 && make install clean

  • if you want APR then - cd /usr/ports/devel/apr && make install clean && cd /usr/ports/www/tomcat-native && make install clean

 

Variant 2 is tested to work great on FreeBSD 7.0 amd64 (x86_64) and java 1.5 - /usr/ports/java/jdk15

 

JBoss 5.1.0.GA

 

The instructions below assume Linux;

 

JBoss 5.1.0.GA uses JBossWeb (a fork of Tomcat) as its servlet container. The steps above (for JBoss 4.2) also apply to JBoss 5.1.0.GA. However, the following may be helpful:

 

  • Use APR 2.0.6
  • Beware that the run script may truncate the ld_library_path - it replaces the existing path with only bin/META-INF/... so the .SO won't load
  • Ensure you have enabled exec on the partition where APR is installed
  • If you are using OpenSSL, startup time will be very slow (>15 minutes) unless you specify SSLRandomSeed="/dev/urandom"
  • Specify SSLRandomSeed for server.xml AprLifecycleListener element
  • If you're still having problems, turn on debugging as described in step 13 above

 

See also this forum thread.