You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by gangadhar p <ga...@gmail.com> on 2008/05/29 22:15:55 UTC

Tomcat 6 clustering

Hi guys, I am configuring Tomcat 6 clustering to have more than one instance
access to each others ServletContext attributes.  It's said that
ServletContext is clustered by default when Tomcat 6 is clustered, but my
servlets in 2 different instances are not able to access each others
ServletContext attributes. The Cluster elements added under the element Host
in two different server.xml files in two different instances are given
below.
In Tomcat Instance 1 :

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

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

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

            <Sender
               
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                replicationMode="pooled"/>
            <Valve
className="org.apache.catalina.cluster.tcp.ReplicationValve"
                  
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
			<ClusterListener 
				
className="org.apache.catalina.cluster.session.ClusterSessionListener"/>

        </Cluster>


In Tomcat Instance 2:

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

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

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

            <Sender
               
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                replicationMode="pooled"/>
            <Valve
className="org.apache.catalina.cluster.tcp.ReplicationValve"
                  
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
			<ClusterListener 
				
className="org.apache.catalina.cluster.session.ClusterSessionListener"/>

        </Cluster>


Pls. let me know if any more changes are needed. It's very urgent.
Thanks a lot in advance for your help.

-- 
View this message in context: http://www.nabble.com/Tomcat-6-clustering-tp17544854p17544854.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 6 clustering

Posted by gangadhar p <ga...@gmail.com>.
Hi again,
I modified the <context> element in the $CATALINA_HOME/conf/context.xml  to
<Context className="org.apache.catalina.ha.context.ReplicatedContext"> and
removed the <Context element from <Host> element in the
$CATALINA_HOME/conf/server.xml  file, and now it's not throwing any error. 

But I still can't retrive from a one instance the attributes set in
ServletContext in another instance.

Any suggestions? 

Thanks again for ur help.






gangadhar p wrote:
> 
> Thanks a lot guys for your prompt response.
> 
> Now I face another error given below: 
> SEVERE: Unable to start ReplicatedContext
> java.lang.ClassCastException:
> org.apache.catalina.cluster.tcp.SimpleTcpCluster
>         at
> org.apache.catalina.ha.context.ReplicatedContext.start(ReplicatedContext.java:61)
>         at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>         at
> org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> 
> The modified server.xml file looks like below:
> 
> 		<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
>                 
> managerClassName="org.apache.catalina.cluster.session.DeltaManager"
>                  expireSessionsOnShutdown="false"
>                  useDirtyFlag="true">
> 
>             <Membership 
>                 className="org.apache.catalina.cluster.mcast.McastService"
>                 mcastAddr="228.0.0.4"
>                 mcastPort="45564"
>                 mcastFrequency="500"
>                 mcastDropTime="3000"/>
> 
>             <Receiver 
>                
> className="org.apache.catalina.cluster.tcp.ReplicationListener"
>                 tcpListenAddress="127.0.0.1"
>                 tcpListenPort="4001"
>                 tcpSelectorTimeout="100"
>                 tcpThreadCount="6"/>
> 
>             <Sender
>                
> className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
>                 replicationMode="pooled"/>
>             <Valve
> className="org.apache.catalina.cluster.tcp.ReplicationValve"
>                   
> filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
> 			<ClusterListener 
> 				
> className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
> 
>         </Cluster>
> 		<Context className="org.apache.catalina.ha.context.ReplicatedContext"
> path="/MyApp" docBase="G:\RealNetworks\apache-tomcat-6.0.16\webapps\MyApp"
> crossContext="true" debug="0" reloadable="true" privileged="true"/>
> 
> 
> Any idea guys on why is that error coming ?
> 
> Thanks a lot again for your help.
> 
> 
> 
> 
> 
> 
> Filip Hanik - Dev Lists wrote:
>> 
>> you'd need to define
>> 
>> <Context className="org.apache.catalina.ha.context.ReplicatedContext" ...
>> 
>> 
>> for each context that you want that to happen
>> 
>> Filip
>> 
>> gangadhar p wrote:
>>> Hi guys, I am configuring Tomcat 6 clustering to have more than one
>>> instance
>>> access to each others ServletContext attributes.  It's said that
>>> ServletContext is clustered by default when Tomcat 6 is clustered, but
>>> my
>>> servlets in 2 different instances are not able to access each others
>>> ServletContext attributes. The Cluster elements added under the element
>>> Host
>>> in two different server.xml files in two different instances are given
>>> below.
>>> In Tomcat Instance 1 :
>>>
>>> 		<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
>>>                 
>>> managerClassName="org.apache.catalina.cluster.session.DeltaManager"
>>>                  expireSessionsOnShutdown="false"
>>>                  useDirtyFlag="true">
>>>
>>>             <Membership 
>>>                
>>> className="org.apache.catalina.cluster.mcast.McastService"
>>>                 mcastAddr="228.0.0.4"
>>>                 mcastPort="45564"
>>>                 mcastFrequency="500"
>>>                 mcastDropTime="3000"/>
>>>
>>>             <Receiver 
>>>                
>>> className="org.apache.catalina.cluster.tcp.ReplicationListener"
>>>                 tcpListenAddress="127.0.0.1"
>>>                 tcpListenPort="4001"
>>>                 tcpSelectorTimeout="100"
>>>                 tcpThreadCount="6"/>
>>>
>>>             <Sender
>>>                
>>> className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
>>>                 replicationMode="pooled"/>
>>>             <Valve
>>> className="org.apache.catalina.cluster.tcp.ReplicationValve"
>>>                   
>>> filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
>>> 			<ClusterListener 
>>> 				
>>> className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
>>>
>>>         </Cluster>
>>>
>>>
>>> In Tomcat Instance 2:
>>>
>>> 		<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
>>>                 
>>> managerClassName="org.apache.catalina.cluster.session.DeltaManager"
>>>                  expireSessionsOnShutdown="false"
>>>                  useDirtyFlag="true">
>>>
>>>             <Membership 
>>>                
>>> className="org.apache.catalina.cluster.mcast.McastService"
>>>                 mcastAddr="228.0.0.4"
>>>                 mcastPort="45564"
>>>                 mcastFrequency="500"
>>>                 mcastDropTime="3000"/>
>>>
>>>             <Receiver 
>>>                
>>> className="org.apache.catalina.cluster.tcp.ReplicationListener"
>>>                 tcpListenAddress="127.0.0.1"
>>>                 tcpListenPort="4002"
>>>                 tcpSelectorTimeout="100"
>>>                 tcpThreadCount="6"/>
>>>
>>>             <Sender
>>>                
>>> className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
>>>                 replicationMode="pooled"/>
>>>             <Valve
>>> className="org.apache.catalina.cluster.tcp.ReplicationValve"
>>>                   
>>> filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
>>> 			<ClusterListener 
>>> 				
>>> className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
>>>
>>>         </Cluster>
>>>
>>>
>>> Pls. let me know if any more changes are needed. It's very urgent.
>>> Thanks a lot in advance for your help.
>>>
>>>   
>> 
>> 
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-6-clustering-tp17544854p17547466.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 6 clustering

Posted by gangadhar p <ga...@gmail.com>.
Thanks a lot guys for your prompt response.

Now I face another error given below: 
SEVERE: Unable to start ReplicatedContext
java.lang.ClassCastException:
org.apache.catalina.cluster.tcp.SimpleTcpCluster
        at
org.apache.catalina.ha.context.ReplicatedContext.start(ReplicatedContext.java:61)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at
org.apache.catalina.core.StandardHost.start(StandardHost.java:719)

The modified server.xml file looks like below:

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

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

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

            <Sender
               
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                replicationMode="pooled"/>
            <Valve
className="org.apache.catalina.cluster.tcp.ReplicationValve"
                  
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
			<ClusterListener 
				
className="org.apache.catalina.cluster.session.ClusterSessionListener"/>

        </Cluster>
		<Context className="org.apache.catalina.ha.context.ReplicatedContext"
path="/MyApp" docBase="G:\RealNetworks\apache-tomcat-6.0.16\webapps\MyApp"
crossContext="true" debug="0" reloadable="true" privileged="true"/>


Any idea guys on why is that error coming ?

Thanks a lot again for your help.






Filip Hanik - Dev Lists wrote:
> 
> you'd need to define
> 
> <Context className="org.apache.catalina.ha.context.ReplicatedContext" ...
> 
> 
> for each context that you want that to happen
> 
> Filip
> 
> gangadhar p wrote:
>> Hi guys, I am configuring Tomcat 6 clustering to have more than one
>> instance
>> access to each others ServletContext attributes.  It's said that
>> ServletContext is clustered by default when Tomcat 6 is clustered, but my
>> servlets in 2 different instances are not able to access each others
>> ServletContext attributes. The Cluster elements added under the element
>> Host
>> in two different server.xml files in two different instances are given
>> below.
>> In Tomcat Instance 1 :
>>
>> 		<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
>>                 
>> managerClassName="org.apache.catalina.cluster.session.DeltaManager"
>>                  expireSessionsOnShutdown="false"
>>                  useDirtyFlag="true">
>>
>>             <Membership 
>>                
>> className="org.apache.catalina.cluster.mcast.McastService"
>>                 mcastAddr="228.0.0.4"
>>                 mcastPort="45564"
>>                 mcastFrequency="500"
>>                 mcastDropTime="3000"/>
>>
>>             <Receiver 
>>                
>> className="org.apache.catalina.cluster.tcp.ReplicationListener"
>>                 tcpListenAddress="127.0.0.1"
>>                 tcpListenPort="4001"
>>                 tcpSelectorTimeout="100"
>>                 tcpThreadCount="6"/>
>>
>>             <Sender
>>                
>> className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
>>                 replicationMode="pooled"/>
>>             <Valve
>> className="org.apache.catalina.cluster.tcp.ReplicationValve"
>>                   
>> filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
>> 			<ClusterListener 
>> 				
>> className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
>>
>>         </Cluster>
>>
>>
>> In Tomcat Instance 2:
>>
>> 		<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
>>                 
>> managerClassName="org.apache.catalina.cluster.session.DeltaManager"
>>                  expireSessionsOnShutdown="false"
>>                  useDirtyFlag="true">
>>
>>             <Membership 
>>                
>> className="org.apache.catalina.cluster.mcast.McastService"
>>                 mcastAddr="228.0.0.4"
>>                 mcastPort="45564"
>>                 mcastFrequency="500"
>>                 mcastDropTime="3000"/>
>>
>>             <Receiver 
>>                
>> className="org.apache.catalina.cluster.tcp.ReplicationListener"
>>                 tcpListenAddress="127.0.0.1"
>>                 tcpListenPort="4002"
>>                 tcpSelectorTimeout="100"
>>                 tcpThreadCount="6"/>
>>
>>             <Sender
>>                
>> className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
>>                 replicationMode="pooled"/>
>>             <Valve
>> className="org.apache.catalina.cluster.tcp.ReplicationValve"
>>                   
>> filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
>> 			<ClusterListener 
>> 				
>> className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
>>
>>         </Cluster>
>>
>>
>> Pls. let me know if any more changes are needed. It's very urgent.
>> Thanks a lot in advance for your help.
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-6-clustering-tp17544854p17546904.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 6 clustering

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
you'd need to define

<Context className="org.apache.catalina.ha.context.ReplicatedContext" ...


for each context that you want that to happen

Filip

gangadhar p wrote:
> Hi guys, I am configuring Tomcat 6 clustering to have more than one instance
> access to each others ServletContext attributes.  It's said that
> ServletContext is clustered by default when Tomcat 6 is clustered, but my
> servlets in 2 different instances are not able to access each others
> ServletContext attributes. The Cluster elements added under the element Host
> in two different server.xml files in two different instances are given
> below.
> In Tomcat Instance 1 :
>
> 		<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
>                 
> managerClassName="org.apache.catalina.cluster.session.DeltaManager"
>                  expireSessionsOnShutdown="false"
>                  useDirtyFlag="true">
>
>             <Membership 
>                 className="org.apache.catalina.cluster.mcast.McastService"
>                 mcastAddr="228.0.0.4"
>                 mcastPort="45564"
>                 mcastFrequency="500"
>                 mcastDropTime="3000"/>
>
>             <Receiver 
>                
> className="org.apache.catalina.cluster.tcp.ReplicationListener"
>                 tcpListenAddress="127.0.0.1"
>                 tcpListenPort="4001"
>                 tcpSelectorTimeout="100"
>                 tcpThreadCount="6"/>
>
>             <Sender
>                
> className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
>                 replicationMode="pooled"/>
>             <Valve
> className="org.apache.catalina.cluster.tcp.ReplicationValve"
>                   
> filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
> 			<ClusterListener 
> 				
> className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
>
>         </Cluster>
>
>
> In Tomcat Instance 2:
>
> 		<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
>                 
> managerClassName="org.apache.catalina.cluster.session.DeltaManager"
>                  expireSessionsOnShutdown="false"
>                  useDirtyFlag="true">
>
>             <Membership 
>                 className="org.apache.catalina.cluster.mcast.McastService"
>                 mcastAddr="228.0.0.4"
>                 mcastPort="45564"
>                 mcastFrequency="500"
>                 mcastDropTime="3000"/>
>
>             <Receiver 
>                
> className="org.apache.catalina.cluster.tcp.ReplicationListener"
>                 tcpListenAddress="127.0.0.1"
>                 tcpListenPort="4002"
>                 tcpSelectorTimeout="100"
>                 tcpThreadCount="6"/>
>
>             <Sender
>                
> className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
>                 replicationMode="pooled"/>
>             <Valve
> className="org.apache.catalina.cluster.tcp.ReplicationValve"
>                   
> filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
> 			<ClusterListener 
> 				
> className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
>
>         </Cluster>
>
>
> Pls. let me know if any more changes are needed. It's very urgent.
> Thanks a lot in advance for your help.
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 6 clustering

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gangadhar,

gangadhar p wrote:
| Hi guys, I am configuring Tomcat 6 clustering to have more than one
instance
| access to each others ServletContext attributes.

It's not going to happen. See the servlet specification:

"
SRV.4.4.1 Context Attributes in a Distributed Container

Context attributes are local to the JVM in which they were created. This
prevents ServletContext attributes from being a shared memory store in a
distributed container. When information needs to be shared between
servlets running in a distributed environment, the information should be
placed into a session (See Chapter SRV.7, “Sessions”), stored in a
database, or set in an enterprise JavaBeans(TM) component.
"

The title of the page for "Apache Tomcat Clustering" is "Apache Tomcat
Clustering - Enable session replication in a Apache Tomcat environment"
and clearly states that it is a HOW-TO on session replication.

| It's said that
| ServletContext is clustered by default when Tomcat 6 is clustered

Really? Where?

See the note in the servlet specification quotation above for ideas on
how to share information between running container instances.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkg/EzYACgkQ9CaO5/Lv0PCzgQCgsENOXktYKIYDG2UdVvb1LnpO
B3gAn3+QWbSKcCKX4VXxrnXnpeGG0wve
=Hxor
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org