Hi I follwoed the below URLs...

http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html
http://tomcat.apache.org/connectors-doc/reference/workers.html
http://tomcat.apache.org/connectors-doc/generic_howto/workers.html

But no luck.. Session is not get replicated..
This is my configuraion

Apache Version : 2.2.4
Tomcat Version : 5.5.17
JDK          :  1.6.0_01
Win 2000

workers.properties

worker.list=tomcat1,tomcat2,loadbalancer

# First tomcat server

worker.tomcat1.type=ajp13
worker.tomcat1.host=192.168.10.30
worker.tomcat1.port=8009
worker.tomcat1.lbfactor=1
worker.tomcat1.connection_pool_timeout=600
worker.tomcat1.socket_keepalive=1
worker.tomcat1.socket_timeout=60
worker.tomcat1.cachesize=20
worker.tomcat1.cache_timeout=180
worker.tomcat1.recycle_timeout=180

# Second tomcat server

worker.tomcat2.type=ajp13
worker.tomcat2.host=192.168.10.50
worker.tomcat2.port=9009
worker.tomcat2.lbfactor=1
worker.tomcat2.connection_pool_timeout=600
worker.tomcat2.socket_keepalive=1
worker.tomcat2.socket_timeout=60
worker.tomcat2.cachesize=20
worker.tomcat2.cache_timeout=180
worker.tomcat2.recycle_timeout=180

worker.tomcat2.lbfactor=100
worker.loadbalancer.type=lb
worker.loadbalancer.sticky_session=True
worker.loadbalancer.balance_workers=tomcat1,tomcat2

Below is the Tomcat1 server.xml.


<Server port="8005" shutdown="SHUTDOWN">

 <Listener className="org.apache.catalina.core.AprLifecycleListener" />
 <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
/>
 <Listener className="
org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
 <Listener className="
org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>


 <GlobalNamingResources>


   <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

   <Resource name="UserDatabase" auth="Container"
             type="org.apache.catalina.UserDatabase"
      description="User database that can be updated and saved"
          factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
         pathname="conf/tomcat-users.xml" />

 </GlobalNamingResources>

 <Service name="Catalina">

   <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
   <Connector port="8081" maxHttpHeaderSize="8192"
              maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
              enableLookups="false" redirectPort="8443" acceptCount="100"
              connectionTimeout="20000" disableUploadTimeout="true" />

   <!-- Define an AJP 1.3 Connector on port 8009 -->
   <Connector port="8009"
              enableLookups="false" redirectPort="8443" protocol="AJP/1.3"
/>

   <!-- Define the top level container in our container hierarchy -->
   <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">

     <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
            resourceName="UserDatabase"/>

     <!-- Define the default virtual host
          Note: XML Schema validation will not work with Xerces 2.2.
      -->
     <Host name="localhost" appBase="webapps"
      unpackWARs="true" autoDeploy="true"
      xmlValidation="false" xmlNamespaceAware="false">


       <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster
"
                managerClassName="
org.apache.catalina.cluster.session.DeltaManager"
                expireSessionsOnShutdown="false"
                useDirtyFlag="true"
                notifyListenersOnReplication="true">

           <Membership
               className="org.apache.catalina.cluster.mcast.McastService"
               mcastAddr="228.0.0.4"
               mcastBindAddress="192.168.10.30"
               mcastPort="45564"
               mcastFrequency="500"
               mcastDropTime="3000"/>

           <Receiver
               className="
org.apache.catalina.cluster.tcp.ReplicationListener"
               tcpListenAddress="auto"
               tcpListenPort="4001"
               tcpSelectorTimeout="100"
               tcpThreadCount="6"/>

           <Sender
               className="
org.apache.catalina.cluster.tcp.ReplicationTransmitter"
               replicationMode="pooled"
               ackTimeout="15000"
               waitForAck="true"/>

           <Valve className="
org.apache.catalina.cluster.tcp.ReplicationValve"

filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>

           <Deployer className="
org.apache.catalina.cluster.deploy.FarmWarDeployer"
                     tempDir="/tmp/war-temp/"
                     deployDir="/tmp/war-deploy/"
                     watchDir="/tmp/war-listen/"
                     watchEnabled="false"/>

           <ClusterListener className="
org.apache.catalina.cluster.session.ClusterSessionListener"/>
       </Cluster>


     </Host>

   </Engine>

 </Service>

</Server>

For Tomcat2 i had changed the below elements only..

<Server port="9005" shutdown="SHUTDOWN">
<Connector port="9081" maxHttpHeaderSize="8192"
              maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
              enableLookups="false" redirectPort="8443" acceptCount="100"
              connectionTimeout="20000" disableUploadTimeout="true" />

   <!-- Define an AJP 1.3 Connector on port 8009 -->
   <Connector port="9009"
              enableLookups="false" redirectPort="8443" protocol="AJP/1.3"
/>
<Membership
               className="org.apache.catalina.cluster.mcast.McastService"
               mcastAddr="228.0.0.4"
               mcastBindAddress="192.168.10.50"
               mcastPort="45564"
               mcastFrequency="500"
               mcastDropTime="3000"/>

Program code..

I had designed a bean and servlet like this..

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import com.bean.SessionCart;

public class SessionStoreServlet extends HttpServlet
{


public synchronized void init (ServletConfig config) throws ServletException

{
       super.init();

}


public void doPost (HttpServletRequest req, HttpServletResponse res)
   throws ServletException, IOException
{

   StringBuffer HTML = new StringBuffer();
   res.setContentType("text/html");
   PrintWriter out = res.getWriter();
   SessionCart sc;
   HttpSession session = req.getSession(true);


       sc= new SessionCart();
       session.putValue("Cart",sc);

       String userName=req.getParameter("loginid");


       ((SessionCart)session.getValue("Cart")).setName(userName);

       out.println("Your account number is " +
((SessionCart)session.getValue("Cart")).getName());
   }

   }
and Bean is like this..

package com.bean;

public class SimpleBean implements java.io.Serializable {


   private String name = null;
   private int age = 0;


   public SimpleBean() {}

   public String getName() {
       return name;
   }

   public void setName(String s) {
       name = s;
   }

}

HTML like this

<form method="POST" action="servlet/SessionStoreServlet">
<input type="text" name="loginid" size="20"></p>
<input type="password" name="password" size="20"></td>
<td width="50%"><input type="submit" value="Submit" name="B1"></td>
     <td width="50%"><input type="reset" value="Reset" name="B2"></td>

I had paste the mod_jk.dll in conf/modules..

What i m trying is
First i started the Apache and then Tomcat1,Tomcat2..
I run the html file in Tomcat1 and the given value is stored in session and
displays the same.
Then stop the Tomcat1..
If i run the same HTML i want to show the session value which is stored in
Tomcat instance1..
But i can not get the old session value..It will start new session only..
Session is not get replicated across Tomcat instances...

Is there is any wrong in my steps?

Replication memebers are added sucessfully in both tomcat instances.. i.e,
replication member messages

are shown in Tomcats but session is not get replicated..

Pls help..
If possible give tested code and server.xml, workers.properties ..
Bcoz no one document is clear abor mod_jk..
I m confused ..
Thanks

Reply via email to