Re: [Cluster] context question

2011-04-11 Thread János Löbb

On Apr 11, 2011, at 12:45 PM, János Löbb wrote:

 Hi,
 
 /Tomcat 7.0.10, OSX 10.6.5, jk 1.2.31, and httpd 2.2.17/
 
 Without any explicit parameters in server.xml, just by setting the jvmRoute 
 attribute in the Engine element and enabling Clustering, session failover 
 worked if I shut down one or the other tomcat instance or the one httpd that 
 was not the reverse proxy.  
 
 However when I just stopped the example webapp in one tomcat, the session did 
 not failover and I received a 404 http error instead of the expected session 
 page from the other tomcat.
 
 Based upon the instructions found in the book:  
 http://proquest.safaribooksonline.com/9780596101060/tomcat_6_clustering_implementation?sessionid=reader=htmlimagepage=
 
 explicitely:
 
 nyissz
 You'll also need to add distributed=true to the webapp's Context element. 
 If there is no Context element declared for it anywhere, you will need to 
 create one. You can create one by making a 
 newCATALINA_HOME/conf/[EngineName]/[HostName]/examples.xml context XML 
 fragment file or by adding one to server.xml.
 nyassz
 
 my thought was that the ReplicatedContect was not initiated.  Well, I already 
 learned that I should not add any context into server.xml and there is 
 nothing in the
 
 bml0066:local administrator$ ls -l tomcat1/conf/Catalina/localhost/
 bml0066:local administrator$ 
 
 directory,  so I created a META-INF directory inside the examples directory 
 and placed a context.xml there with the following content:
 
 bml0066:local administrator$ cat 
 tomcat1/webapps/examples/META-INF/context.xml 
 ?xml version=1.0 encoding=UTF-8?
 Context className=org.apache.catalina.ha.context.ReplicatedContext 
 distributed=true 
 /Context
 
 I did it on both tomcats and bounced them.  Now when I look the log, I see 
 the following warning just after restart:
 
 INFO: Deploying web application directory examples
 Apr 11, 2011 12:00:28 PM org.apache.catalina.startup.SetContextPropertiesRule 
 begin
 WARNING: [SetContextPropertiesRule]{Context} Setting property 'distributed' 
 to 'true' did not find a matching property.
 Apr 11, 2011 12:00:28 PM 
 org.apache.catalina.tribes.tipis.AbstractReplicatedMap init
 INFO: Initializing AbstractReplicatedMap with context name:/examples
 Apr 11, 2011 12:00:28 PM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: contextInitialized()
 Apr 11, 2011 12:00:28 PM org.apache.catalina.core.ApplicationContext log
 INFO: SessionListener: contextInitialized()
 
 
 So the first question is, should I use the distributed=true property here ? 
  Is the book right ?  I think it is from 2007.  I already have the 
 distributable/ tag in the webapp's web.xml.
 
 The second question is what to do to avoid the 404 message and fail the 
 session over instead of it, when I just stop the webapp on the tomcat 
 instance?  By default I am using sticky sessions.
 
 nyissz
 bml0066:local administrator$ cat apache2/conf/workers.properties 
 worker.list = lb,jkstatus
 
 worker.lb.type=lb
 worker.lb.balance_workers=tomcat1,tomcat3
 #,tomcat2,tomcat4
 worker.lb.sticky_session = True
 worker.lb.sticky_session_force = False
 
 worker.jkstatus.type=status
 
 worker.tomcat1.type = ajp13
 worker.tomcat1.host = bml0066.yalepath.org
 worker.tomcat1.port = 8109
 worker.tomcat1.lbfactor = 1
 worker.tomcat1.redirect=tomcat3
 
 #worker.tomcat2.type = ajp13
 #worker.tomcat2.host = bml0066.yalepath.org
 #worker.tomcat2.port = 8209
 #worker.tomcat2.lbfactor = 1
 #worker.tomcat2.redirect=tomcat4
 
 worker.tomcat3.type = ajp13
 worker.tomcat3.host = bml0065.yalepath.org
 worker.tomcat3.port = 8309
 worker.tomcat3.lbfactor = 1
 worker.tomcat3.redirect=tomcat1
 
 #worker.tomcat4.type = ajp13
 #worker.tomcat4.host = bml0065.yalepath.org
 #worker.tomcat4.port = 8409
 #worker.tomcat4.lbfactor = 1
 #worker.tomcat4.redirect=tomcat2
 
 nyassz
 
 Thanks ahead,
 
 János
 
 
 


Testing out he examples webapp I found this in the log of that tomcat where I 
shut down the webapp:

nyissz
INFO: Server startup in 6625 ms
Apr 11, 2011 12:43:59 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: 
sessionCreated('1CAEC5FA2D27A7410C819A8BBF9E7F77.tomcat1')
Apr 11, 2011 12:47:23 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: 
sessionCreated('69EB2E77CE0D912F8584E60B4CB828D7.tomcat3')
Apr 11, 2011 12:47:46 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: 
attributeAdded('69EB2E77CE0D912F8584E60B4CB828D7.tomcat3', 's1', 't3')
Apr 11, 2011 12:48:40 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Associated with Deployer 
'Catalina:type=Deployer,host=localhost'
Apr 11, 2011 12:48:40 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Global resources are available
Apr 11, 2011 12:48:54 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 11, 2011 12:49:01 PM 

Re: [Cluster] context question

2011-04-11 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

János,

On 4/11/2011 12:45 PM, János Löbb wrote:
 bml0066:local administrator$ ls -l tomcat1/conf/Catalina/localhost/
 bml0066:local administrator$ 
 
 directory,  so I created a META-INF directory inside the examples directory 
 and placed a context.xml there

You have confused things: META-INF/context.xml goes into your WAR file
(or exploded WAR webapp directory). If you want to use
tomcat1/conf/Catalina/localhost/, you'll want the file to be called
tomcat1/conf/Catalina/localhost/examples.xml

 with the following content:
 
 bml0066:local administrator$ cat 
 tomcat1/webapps/examples/META-INF/context.xml 
 ?xml version=1.0 encoding=UTF-8?
 Context className=org.apache.catalina.ha.context.ReplicatedContext 
 distributed=true 
 /Context

Specifying the className for the Context shouldn't be necessary.

There is no distributed attribute in the Context element.

You should be configuring distributed/ in web.xml, not in context.xml.

http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html

 So the first question is, should I use the distributed=true property here ? 
  Is the book right ?

That book was published before TC 7 was available, so some things may
have changed.

 I think it is from 2007.  I already have the distributable/ tag in the 
 webapp's web.xml.

That should be all you need, plus a Cluster configuration in
server.xml. Read the Cluster HOWTO document above.

 The second question is what to do to avoid the 404 message and fail the 
 session over instead of it, when I just stop the webapp on the tomcat 
 instance?  By default I am using sticky sessions.

distributable + clustering should result in session fail-over with our
without sticky sessions. One could argue that session session stickiness
is not necessary if you are fully replicating your sessions across the
cluster -- though you may have some transient state that needs to be
re-built on a fail-over target that might use more memory or resources
in which case stickiness is useful.

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

iEYEARECAAYFAk2jTdgACgkQ9CaO5/Lv0PAmUgCfVnrQRzku3/LzRoHNKYXYaUR1
DbYAnigFW9zo6QtGGlpC4KnIM5Nuz1Yq
=KkFg
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org