I was recently working with the creating axis2 cluster by using tomcat. Instead of running axis as two different webapps in one tomcat instance, I used two different tomcat instances to create the cluster. But i faced a problem which is already mentioned in here.
java.lang.NullPointerException at org.apache.axis2.clustering.state.DefaultStateManager.updateContexts(DefaultStateManager.java:81) at org.apache.axis2.clustering.state.Replicator.replicate(Replicator.java:102) at org.apache.axis2.receivers.AbstractMessageReceiver.replicateState(AbstractMessageReceiver.java:69) at org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceiver.java:73) at org.apache.axis2.receivers.AbstractMessageReceiver$AsyncMessageReceiverWorker.run(AbstractMessageReceiver.java:301) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
I digged in to see the root cause for this and found that the ClusteringAgent (TribesClusteringAgent) was never initialized and this was causing the NPE in DefaultStateManager. This was because, by default, the parameter “AvoidInitiation” is set as “true” under the clustering section in axis2.xml. So when running axis2 in tomcat, this skips the initiation of the cluster when the ConfigurationContext is being build. This parameter is set to true if initialization is explicitly done by some other party other than axis2 server it self. This issue can be overcome by setting the parameter as “false“. Then the clustering works as expected.
This post explains more about axis2 clustering on tomcat in detail.