Running newjc

Review newjc output

Tell Apache about mod_jk

# Generating the JOnAS's cluster configuration with newjc

## Running newjc

newjc is a tool included in JOnAS that constructs and configures the JOnAS bases (JOnAS instances) for the cluster. It also creates the configuration files needed for mod_jk.
This tool is located under $JONAS_ROOT/examples/sampleCluster2/newjc.

newjc can be used to configure cluster configurations other than sampleCluster2. These configuration files are basic and can be edited as needed to fit site requirements.

newjc can customize some of the characteristics of the cluster through the build-jc.properties, build-db.properties, build-master.properties and jonas-newjc.properties files.

The default configuration is located at $JONAS_ROOT/examples/sampleCluster2/newjc/build-jc.properties. This file should not require modifications for sampleCluster2, unless there are port conflicts. Port assignments for sampleCluster2 are also summarized in $JONAS_ROOT/examples/sampleCluster2/PortConfiguration.txt. This file is for documentation only and is not used by newjc.

### Running newjc to configure sampleCluster2

Before newjc is run for the first time on Linux, create the following directory: $HOME/jc.config/lib

mkdir –p $HOME/jc.config/lib

Run newjc.

cd $JONAS_ROOT/examples/sampleCluster2/newjc

./newjc.sh

Here is an example output. Script output is in gray. User inputs are black and bold.

> > > Buildfile: ./build-jc.xml

> > > init:

> > > create_jonas_cluster:

> > > [input] Choose your output directory : [default : ${myenv.JONAS_BASE}] :

> > > /home/<user>/cluster

> > > [input] Choose your prefix for the JONAS_BASE directories : [default : jb] :

> > > jb

> > > [input] Choose your protocol : [default : cmi] :(jrmp,jeremie,iiop,cmi,)

> > > cmi

> > > [input] Choose your database : [default : hsql] :

> > > hsql

> > > [input] Choose your WebContainer : [default : tomcat] :(tomcat,)

> > > tomcat

> > > [input] Choose your cluster architecture [bothWebEjb/diffWebEjb] : [default : diffWebEjb] :(bothWebEjb,diffWebEjb,)

> > > diffWebEjb

> > > [input] Choose the number of web instances : [default : 2] :

> > > 2

> > > [input] Choose the number of ejb instances : [default : 2] :

> > > 2

/// newjc output deleted for brevity

Files created by newjc will be discussed in the following section.

Note: On Windows the steps are the same, except,

create the folder C:\Documents and Settings\<user>\jc.config\lib

Run the newjc.cmd

For more information about newjc refer to the ObjectWeb site.

## Review newjc output

Newjc created tomcat_jk.conf and workers.properties files. For sampleCluster2 they are located in /home/<user>/cluster/conf/jk.
The #Web section of build-jc.properties defines configuration parameters set in these files by newjc.

Refer to workers how to documentation on the Tomcat site.

tomcat_jk.conf contains apache directives supported in httpd.conf or apache2.conf. They are isolated in a separate file for modularity, then included in httpd.conf or apache2.conf.
newjc also generated four JOnAS instances (JONAS_BASE) in directories jb1, jb2, jb3 and jb4 under /home/<user>/cluster. Configuration files are all in the conf directory of each JOnAS instance. The files pertinent to cluster are described below.

jb1 and jb2 are sampleCluster2 JOnAS web container instances. jb3 and jb4 are sampleCluster2 JOnAS EJB container instances.

newjc generated a script (jcl4sc2) for controlling the cluster (start/stop/kill).

### carol.properties and jgroups-cmi.xml

The #Carol section of build-jc.properties defines configuration parameters set in the carol.propetries file and jgroups-cmi.xml by newjc.

This allows JNDI replication to support load balancing at the EJB level using the CMI protocol.

Note: The multicast address and port must be identically configured for all JOnAS/Tomcat instances.

### jonas.properties

The #Services section of build-jc.properties defines configuration parameters set in the jonas.properties file by newjc.

### server.xml

The #Web section of build-jc.properties defines some configuration parameters set in the server.xml file by newjc.
In particular, a connector XML element for AJP1.3 protocol is defined, as well as a jvmRoute to support load balancing at the web level, via this connector.

A Cluster XML element was also added. It defines parameters for achieving Session replication at the web level with JOnAS.

Refer to the AJP Connector and the Engine Container documentation.

Note: The jvmRoute name generated by newjc is the same as the name of the associated worker defined in worker.properties. This will ensure the Session affinity.

### jcl4sc2 (jcl4sc2.bat)

These files are scripts to run the sampleCluster2 cluster on Linux and Windows.

## Tell Apache about mod_jk

To make apache aware of this new file, edit <prefix>/conf/httpd.conf.
Copy and paste the following line after the Dynamic Shared Object (DSO) Support section.

Include conf/jk/tomcat_jk.conf

Move the jk directory created by newjc under the APACHE structure:

<mv /home/<user>/cluster/conf/jk $APACHE_HOME/conf>

Restart apache so that apache can load the jk_module: <apachectl stop && apachectl start>

Note that some UNIX distributions may locate the module in the folder libexec instead of the folder modules.