tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From János Löbb <janos.l...@yale.edu>
Subject Re: [Cluster] context question
Date Mon, 11 Apr 2011 17:02:48 GMT

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=html&imagepage=
> 
> 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 org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: stop: Stopping web application '/examples'
Apr 11, 2011 12:49:01 PM org.apache.catalina.ha.session.DeltaManager stopInternal
INFO: Manager [localhost#/examples] expiring sessions upon shutdown
Apr 11, 2011 12:49:01 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: sessionDestroyed('69EB2E77CE0D912F8584E60B4CB828D7.tomcat3')
Apr 11, 2011 12:49:01 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: attributeRemoved('69EB2E77CE0D912F8584E60B4CB828D7.tomcat3', 's1',
't3')
Apr 11, 2011 12:49:01 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: sessionDestroyed('1CAEC5FA2D27A7410C819A8BBF9E7F77.tomcat1')
Apr 11, 2011 12:49:01 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Apr 11, 2011 12:49:01 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Apr 11, 2011 12:49:01 PM org.apache.catalina.core.ApplicationContext log
SEVERE: HTMLManager: ManagerServlet.stop[/examples]
java.lang.NullPointerException
	at org.apache.catalina.ha.context.ReplicatedContext.stopInternal(ReplicatedContext.java:86)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)
	at org.apache.catalina.manager.ManagerServlet.stop(ManagerServlet.java:1273)
	at org.apache.catalina.manager.HTMLManagerServlet.stop(HTMLManagerServlet.java:754)
	at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:222)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:591)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:333)
	at org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:218)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	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:680)
Apr 11, 2011 12:49:01 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 11, 2011 12:49:48 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: start: Starting web application '/examples'
Apr 11, 2011 12:49:48 PM org.apache.catalina.core.ApplicationContext log
SEVERE: FAIL - Application at context path /examples could not be started
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_start])
for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/examples]]
in state [STOPPING]
	at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:386)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1223)
	at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:735)
	at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:220)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:591)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:333)
	at org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:218)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	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:680)
Apr 11, 2011 12:49:48 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
<nyassz>

so, tomcat did go into a state that does not allow the app be started correctly via the manager
webapp.  When I try to access it via a browser I receive:

<nyissz>
HTTP Status 404 - /examples/servlets/servlet/SessionExample

type Status report

message /examples/servlets/servlet/SessionExample

description The requested resource (/examples/servlets/servlet/SessionExample) is not available.

Apache Tomcat/7.0.10

<nyassz>

I have to restart the tomcat instance and all the other webapps with it to get it out from
that stage producing the 404 message.

Is there a better way ?

Thanks ahead,

János



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message