En JBoss 5 basta con configurar la entrada de jvmRoute en server/default/deploy/jbossweb.sar/server.xml (bajo Engine) para habilitar el conector de JK:

root@ias # more /data/jboss/jboss/server/default/deploy/jbossweb.sar/server.xml
(...)
      <Engine name="jboss.web" defaultHost="localhost" jvmRoute="jboss1">
         <Realm className="org.jboss.web.tomcat.security.JBossWebRealm"
            certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
            allRolesMode="authOnly"
            />
(...)

Sobretodo es importante que el valor de jvmRoute coincida con el que establecemos en mod_jk.conf en Apache para este nodo. Una forma de verificar que funciona correctamente el sistema de balanceo es desplegando el siguiente jsp, que nos permite ver que las sesiones quedan con el ‘tag’ del jvmRoute marcado al final (.jboss1, .jboss2…):

<%@ page contentType='text/html' pageEncoding='GBK' %>
<pre style='font-size: 12px;'>
<%
String sUserName=(String)session.getAttribute ("username");
Integer oRequestCounter=(Integer)session.getAttribute ("request counter");
int iRequestCounter = oRequestCounter!=null ? oRequestCounter.intValue() : 0;
iRequestCounter ++;
session.setAttribute ("request counter", Integer.valueOf(iRequestCounter));
java.sql.Timestamp oSessionCreatedTime = new
java.sql.Timestamp(session.getCreationTime());
java.sql.Timestamp oSessionLastAccessedTime = new
java.sql.Timestamp(session.getLastAccessedTime());
String sSessionID = session.getId ();
java.sql.Timestamp currentTimestamp=new
java.sql.Timestamp(System.currentTimeMillis());
String sInfo =
"-------------------------------------------n" +
"Request: # " +iRequestCounter + "n" +
" Time: " + currentTimestamp + "n" +
"Session:n" +
" ID " + sSessionID + "n" +
" Created " + oSessionCreatedTime + "n" +
" Accessed " + oSessionLastAccessedTime + "n" +
" Attribute: username = " + sUserName + "n" +
" Attribute: request counter = " + session.getAttribute ("request counter") + "n" + "";
System.out.println (sInfo);
out.println (sInfo);
if (sUserName==null)
{
session.setAttribute ("username", "MyName "+new
java.sql.Time(System.currentTimeMillis()));
}
%>
</pre>

Y testeándolo contra el JBoss de turno (por ejemplo http://host:8080/session-test.jsp ) nos dará:

-------------------------------------------
Request: # 2
 Time: 2010-07-13 15:13:14.342
Session:
 ID 38141E2483F6AE7C9D734FE7ABFAD405.jboss2
 Created 2010-07-13 14:50:38.626
 Accessed 2010-07-13 15:13:03.904
 Attribute: username = MyName 14:50:38
 Attribute: request counter = 2