Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:ec2-54-245-60-219.us-west-2.compute.amazonaws.com:11211,n2:ec2-54-245-98-228.us-west-2.compute.amazonaws.com:11211"
failoverNodes="n1"
sessionBackupAsync="false"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
Tomcat 2Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:ec2-54-245-60-219.us-west-2.compute.amazonaws.com:11211,n2:ec2-54-245-98-228.us-west-2.compute.amazonaws.com:11211"
failoverNodes="n2"
sessionBackupAsync="false"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
And the exception which is being thrown is
Oct 18, 2012 9:46:02 AM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Oct 18, 2012 9:46:02 AM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Oct 18, 2012 10:23:16 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Oct 18, 2012 10:23:16 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 18, 2012 10:23:16 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1660 ms
Oct 18, 2012 10:23:17 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Oct 18, 2012 10:23:17 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
Oct 18, 2012 10:23:17 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
Oct 18, 2012 10:23:17 AM de.javakaffee.web.msm.MemcachedSessionService startInternal
INFO: MemcachedSessionService starts initialization... (configured nodes definition n1:ec2-54.245.97.203.us-west-2.compute.amazonaws.com:11211,n2:ec2-54-245-98-229.us-west-2.compute.amazonaws.com:11211, failover nodes null)
Oct 18, 2012 10:23:17 AM org.apache.catalina.core.StandardContext start
SEVERE: Error manager.start()
java.lang.RuntimeException: Could not create memcached client
at de.javakaffee.web.msm.MemcachedSessionService.createMemcachedClient(MemcachedSessionService.java:468)
at de.javakaffee.web.msm.MemcachedSessionService.startInternal(MemcachedSessionService.java:404)
at de.javakaffee.web.msm.MemcachedBackupSessionManager.startInternal(MemcachedBackupSessionManager.java:140)
at de.javakaffee.web.msm.MemcachedBackupSessionManager.start(MemcachedBackupSessionManager.java:649)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4714)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:48)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:505)
at net.spy.memcached.MemcachedConnection.createConnections(MemcachedConnection.java:122)
at net.spy.memcached.MemcachedConnection.<init>(MemcachedConnection.java:106)
at net.spy.memcached.DefaultConnectionFactory.createConnection(DefaultConnectionFactory.java:153)
at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:186)
at de.javakaffee.web.msm.MemcachedSessionService.createMemcachedClient(MemcachedSessionService.java:466)
... 26 more
Oct 18, 2012 10:23:17 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/host-manager] startup failed due to previous errors
Oct 18, 2012 10:23:17 AM de.javakaffee.web.msm.MemcachedSessionService shutdown
INFO: Stopping services.
Oct 18, 2012 10:23:17 AM org.apache.catalina.core.StandardContext start
SEVERE: Exception during cleanup after start failed
java.lang.NullPointerException
at de.javakaffee.web.msm.MemcachedSessionService.shutdown(MemcachedSessionService.java:380)
at de.javakaffee.web.msm.MemcachedBackupSessionManager.stop(MemcachedBackupSessionManager.java:682)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4882)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4750)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Oct 18, 2012 10:23:17 AM org.apache.tomcat.util.modeler.Registry registerComponent
Can you tell me where should I need to change?
HI Martin,
I have implemented memcached session manager for both sticky and non-sticky session.
1. In case of non-sticky sessions, the session data is getting transferred between two tomcats running on two EC2 instances.
2. In
case of load balancer with sticky sessions, it is working fine. But when you
stop one instance, after restarting,the private ip of the instance will change.
But the other instance which was running initially, will store the session data
into the memcached node of stopped instance. So after restarting the instance,
the session won’t be available in the restarted instance as its private ip will
be changed.
How can I overcome this issue?
How does an ec2 instance know about other instances, how do you configure memcached nodes in the tomcats? Do you start the instances, check their ips and then configure memcachedNodes accordingly?
Cheers,
Martin
HI Martin,
I have implemented memcached session manager for both sticky and non-sticky session.
1. 1. In case of non-sticky sessions, the session data is getting transferred between two tomcats running on two EC2 instances.
2. 2. In case of load balancer with sticky sessions, it is working fine. But when you stop one instance, after restarting,the private ip of the instance will change. But the other instance which was running initially, will store the session data into the memcached node of stopped instance. So after restarting the instance, the session won’t be available in the restarted instance as its private ip will be changed.