Adding APR to JBoss

From OpenKM Documentation
Jump to: navigation, search

Out-of-the-box, JBoss AS 4.2.3 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 you can add the Apache Portable Runtime (APR) to achieve native HTTP processing performance.

If you run JBoss, you can notice certain console output that indicates no APR presence:

 ...
 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/java-6-sun-1.6.0.24/jre/lib/i386/server:/usr/java/java-6-sun-1.6.0.24/jre/lib/amd64:/usr/java/java-6-sun-1.6.0.24/jre/../lib/amd64
 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.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)] Started in 23s:669ms

Stop JBoss and download JBoss Native from http://www.jboss.org/jbossweb/downloads. It is very important that you choose the right native-built libraries for your operating system. Extract the archive into $JBOSS_HOME:

 $ cd jboss-4.2.3.GA
 $ tar xzvf jboss-native-2.0.8-linux2-x64-ssl.tar.gz

Now you have a folder $JBOSS_HOME/bin/native with some dynamic libraries. Re-run JBoss AS, which will now detect the presence of the native libraries:

 $ ./bin/run.sh

Notice certain console output that indicates the presence of the APR:

 ...
 17:35:39,240 INFO  [AprLifecycleListener] Loaded Apache Tomcat Native library 1.1.18.
 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.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)] Started in 18s:462ms

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.

See also: