Session is not Migrated when I use HttpSessionActivationListener .

Hi all,
I studied about HttpSessionActivation Listener and in order understand it fully I created a simple program . I studied that the listener will be invoked whenever session attribute is migrated from one JVM to another .
The following was what I did to understand HttpSessionActivationListener
Created two instances of Tomcat in a single box.(Actually two services)
Configured Apache Http Server to point the two instances (Load balancing and fail over) [Using this link|http://thought-bytes.blogspot.com/2007/03/how-to-load-balance-tomcat-55-with.html]
Created a small web application and deployed in two servers
Source codes
===========
SessionMigrationTester Listener
package c6;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class SessionMigrationTester implements HttpSessionActivationListener,Serializable { //Implemented Serializable Interface
     public void sessionDidActivate(HttpSessionEvent evt){
          System.out.println("========================");
          System.out.println("Session DID Activated --**-- Serializable");
          System.out.println("========================");
     public void sessionWillPassivate(HttpSessionEvent evt){
          System.out.println("========================");
          System.out.println("Session WILL Passivate --**-- Serializable");
          System.out.println("========================");
}Web.xml
========
<web-app>
<servlet>
     <servlet-name>SessionTest</servlet-name>
     <servlet-class>c6.SessionExample</servlet-class>     
</servlet>
<servlet>
     <servlet-name>servlet3</servlet-name>
     <servlet-class>c6.Servlet3</servlet-class>
</servlet>
<servlet-mapping>
     <servlet-name>SessionTest</servlet-name>
     <url-pattern>/sessiontest.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
     <servlet-name>servlet3</servlet-name>
     <url-pattern>/servlet3.do</url-pattern>
</servlet-mapping>
</web-app>SessionExample.java
package c6;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SessionExample extends HttpServlet {
     public void doGet(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException {
          System.out.println("Inside doGet method ");
          PrintWriter out = resp.getWriter();
          resp.setContentType("text/html");
          HttpSession session = req.getSession(false);
          out.println("<html>");
          out.println("<head> ");
          out.println("</head>");
          out.println("<body>");
          out.println("<form >");
          if(session ==null){
               System.out.println("No Session exists creating a new one ....");
               session = req.getSession(true);
               String sessionID = session.getId();
               if(session.isNew()){
                    session.setAttribute("hello",new SessionMigrationTester());
                    out.println("New session is created ID:- "+sessionID);
                    System.out.println("New session is created ID:- "+sessionID);
          }else {
               String sessionID = session.getId();
               session.setAttribute("hello",new SessionMigrationTester());
               out.println("Old session ID:- "+sessionID);
               System.out.println("Old session ID:- "+sessionID);
          out.println("Modified ***<br/>");
          out.println("<input type='submit' value='click me' />");
          out.println("<script lang='javascript'>");
          out.println("document.forms[0].action ="+"\""+resp.encodeURL("servlet3.do")+"\"");
          out.println("</script>");
          out.println("</form>");
          out.println("</body>");
          out.println("</html>");
          System.out.println("End of doGet");
     public void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException {
          doGet(req,resp);
}Servlet3.java
=========
package c6;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Servlet3 extends HttpServlet {
     public void doGet(HttpServletRequest req,HttpServletResponse resp)
     throws ServletException,IOException {
          HttpSession session = req.getSession(false);
          if(session!=null){
               System.out.println("Session Already Exists! "+session.getId());
          }else{
               System.out.println("Session doesn't exists!!!");
     public void doPost(HttpServletRequest req,HttpServletResponse resp)
     throws ServletException,IOException {
          doGet(req,resp);
}Whenever I stop one instance(say "Tomcat instance 1") I'm getting a message "Session Will Passivated "(which is what I have in overridden sessionWillPassivate method)
I'm also getting "Session Did Activated" message (overridden in sessionDidActivated method) whenever I start the same instance(say "Tomcat instance 1").
What I expected
============
After stopping the Tomcat instance (say "Tomcat instance 1") I reloaded the same page expecting this time it will be served by another Tomcat instance(say "Tomcat Instance 2" and I will get "SessionDidActivated" message from "Tomcat instance 2" but it didn't worked as I expected instead the page is served by another Tomcat instance("Tomcat instance 2") but the session is not migrated and I'm not getting "SessionDidActivated" in the new Tomcat instance.
I also created a new Servlet named as (Servlet3) and modified SessionExample.java to this .so that It contains button and when it clicked it will hit a new Servlet(Servlet 3) but it also doesn't help.
I'm trying this in a single physical machine with two tomcat instance configured with Apache Http Server .
Is anything I'm missing ?
Please clarify me why the session is not migrated .
Thanks in advance

Hi ejp,
One more question I have . Today I tried to find out why the listener class is not invoked(I doesn't get "SessionDidActivated" and "SessionWillPassivate" sysouts from listener class) and found that when I enable clustering in Tomcat it's doesn't works(even though session migrates) and when I switch back to normal mode it does work .
Following is the fragment I uncomment to enable clustering
<!--
        <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"
                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>
-->Am just curious to know why it happens like this .
Can you please clarify me ?

Similar Messages

  • I have a 17" Macbook pro with flickering red and cyan(blue) lines across the screen. The issue disappears temporarily when I tap on the computer, and the problem does not occur when I use external display or try to screen capture the problem.

    I purchased my Macbook (17") through a certified apple tecnition in August 2012, it was refurbished and the motherboard was completely replaced. I do a lot of photo editing, but I have been unable to do so because of the red vibrating lines that interrupt my screen. The issue disappears temporarily when I tap on the computer, and the problem does not occur when I use external display or try to screen capture the problem. I brought the computer back to the technition I purchased it from and he said that it was a problem with my fan, so I have two new fans but the issue is still occuring. He says he doesnt know whats wrong. Does anyone have any information on this issue?
    Here is an image of the issue
    http://www.flickr.com/photos/67839707@N08/8884847081/

    I recommend having your Mac serviced by someone competent. A force sufficient to "blow apart" the fans was clearly excessive and may have damaged the display cable, as well as any number of other problems.
    Dust is properly cleaned with a vacuum, preferably one designed for computer service, and they are not cheap.
    Compressed air should never be used. It just blows dust everywhere, often into places where it can no longer be removed.

  • Red Hat Enterprise Linux Test Page - why am I directed to this page when I go to a specific website. It does not happen when I use other browsers so there is not a problem with the website.

    Red Hat Enterprise Linux Test Page - why am I directed to this page when I go to a specific website. It does not happen when I use other browsers so there is not a problem with the website.
    Just started happening yesterday.

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Do you see any prefs related to that <b>knoxnews<i></i>.com</b> site on the <b>about:config</b> page if you enter that URL in the Filter?
    *http://kb.mozillazine.org/about:config
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • I have a folder with 10 folders inside it, 8 of the folders will not function when I use "show view options".

    I have a Folder with 10 Folders inside it, 8 of the Folders will not function when I use "show view options", they always default back the default.  The "show view options" works on all my other Folders in my system, even on the first two of the Folder in question.  How can I correct it?  I have tried every thing I can think of, even deleting the Folders & reintalling them.  For some strange reason the "show view options" only does not work on the last 8 Folders in the Folder in question.

    Instead GarageBand recognize my keyboard and i can play normally, also, if it can help, those are the Audio and Midi Logic Preferences and the Controller Surfaces Setup with the keyboard connected :

  • My iphone 4 ,new update give me not happie ,when i use yahoo messenger little whow there freeze my phone

    my iphone 4 ,new update give me not happie ,when i use yahoo messenger freeze

    Basic troubleshooting from the User's Guide is reset, reset, restore (first from backup then as new).  Try each of these in order until the issue is resolved.

  • I have been organizing my bookmarks into folders. There are a bunch of bookmarks that appear on the Bookmarks Menu that do not appear when I used the Organize Bookmarks option. Therefore I can't organize them. How do I get at them and move them to folders

    I used Organize Bookmarks to put some bookmarks in folders. When I had done all the bookmarks that appeared outside of folders in the Organize Bookmarks window, I closed it and looked at my bookmarks menu. Under my folders were some other bookmarks that I hadn't seen in Organize Bookmarks and when I used it again, they still weren't visible. Therefore, I couldn't move them into folders.

    Update - I discovered that the entire list of bookmarks can be accessed in the Organize Bookmarks window by clicking on the icon for Bookmarks Menu.
    This seem like odd interface behaviour to me.
    All the other software I use follows the pattern that an icon with a triangle to the left, which you click on to expand the menu tree downwards, shows the entire contents of the category when you click on the triangle. In other words, you don't get a different response by clicking on the icon from what you get by clicking on the triangle.
    It also seems odd to me that when an unsorted bookmarks folder is automatically provided that unsorted bookmarks would not be placed there by default.
    Anyway, by getting the list of bookmarks displayed this way I was able to simply right-click on items in the list and delete them, as I thought I should be able to do. Problem solved. Organize Bookmarks interface found to be somewhat unintuitive.

  • Scroll bar does not slide when dragged using curser in word

    I need answers to two questions.
    1.   How to maximise a word document to full window size.
    2.   Why the side scroll bar of a document does not slide when dragged.
    3.   Am very  used to the "delete", "page up and page down" keys and cant find them on keyboard.
    Thanks.

    What you can try if the above doesn't work, is deleting the scroll bar from your Data List, and then dropping it back in from the Library. The act of re-adding the scrollbar may get you the desired behavior.
    If that doesn't work, you will probably need to post your project so we can take a look.
    -Bear

  • IIS service not showing when I use the get-exchangeCertificate | fl cmdlet

    Hello All,
    I just installed a 3rd party digital certificate to my Exchange 2010 via powershell then assigned the 4 services IIS, pop, smtp, imap but when I use the get-exchangecertificate | fl cmdlet the IIS service is not showing.The rest of the services were fine. 
    During the process of installing the certificate via powershell, I got a message that says: Do you want to enforce SSL communication on the root web
    site? If not, rerun the cmdlet with the -DoNotRequireSSL parameter. I said No to all and the operation continued. By the way, I also invoke the iisreset /restart right after installing the digital
    certificate. I then proceeded to install my root certificate and intermediate certificates. All were imported successfully via certificate snap-in. When I access the exchange 2010 EMC console, the status for the Exchange Certificate still says pending certificate
    signing request. Not sure if that is related at all to the fact that IIS service is not showing amongst the assigned services listed. Any idea why IIS service is not in the list of assigned services for Exchange certificate?? Can I re-run my powershell and
    repeat my steps, but this time just assigned IIS service alone? Or should I re-run powershell altogether and assign all 4 services again??? Also, what about the pending certificate signing request in the EMC console should I process and complete the request??
    Any advise is appreciated. Let me know please.
    Thanks!
    Lotusmail1
    Franz Garcia

    Hi Lotusmail1,
    Please run the following command to just assign IIS service to this third-party certificate (using certificate 5113ae0233a72fccb75b1d0198628675333d010e as a example), then run Get-ExchangeCertificate to check it again:
    Enable-ExchangeCertificate -Thumbprint 5113ae0233a72fccb75b1d0198628675333d010e -Services IMAP,POP,IIS,SMTP
    Regards,
    Winnie Liang
    TechNet Community Support

  • APPS Adapter / Business Events not visible when BPEL uses non-apps user

    We have BPEL connection using custom oracle user, xx_b2b and when we use APPS adapter in BPEL, I can not see and use any business event.
    If anybody across same requirement, please share your experience.
    Appreciate help on this.
    Thanks,
    Sonartori

    Hi,
    I'm facing the same issue. Were you able to resolve it. Appreciate if you can let me know.
    Thanks
    -Prapoorna

  • How to use Derivative x(t) PtbyPT , I'm not sure, when i use.

    when i use this function i'm not sure that i connect its correct or not, could you help me for checking?
    but i saw  that the output of integral x(t)  PtbyPT  is very large, it's correct or not?
    Attachments:
    TEST.vi ‏68 KB

    Hi
    You can used the function in a seperate VI and check the output for a known value. When I am running your Vi i am not able to recreate the problem which you are saying.
    but i saw  that the output of integral x(t)  PtbyPT  is very large, it's correct or not?very large means what?
    Just try using the derivative vi seperately and you will know whether you are getting the results are right
    Regards

  • Will not charge when in use...

    My macbook is less than a year old, and has a brand new battery but will still not charge when it is in use. It only charges when it is closed or shut down. Since the battery is new I dont think that is the problem, and I have had my charger checked and that seems to be working properly. I have no idea what could be wrong unless there is something wrong with the computer itself. I have tried multiple outlets in different places. Please help! Thanks

    I figured it out.   I took the battery out and put it back in.  Ding Ding Ding  That worked, now it is charging.  How in the world did it work off the battery if it was not plugged in tight enough to charge??? Oh well, it works again.  Thanks

  • My apple I'd does not work when I use it on my iPhone

    My apple I'd does network when I use my iPhone, but is ok when I use my iPad.   Wat is the problem?

    None of this appears to work for me.    It would seem people might want to do this fairly often.  Like if you gave an old ipad to your kid when you got your new one.
    Seems impossible to change.
    Plus people are going to use both multiple Apple devices on the same computer and the same Apple device on multiple computers.  Apple needs to do a MUCH better job reflecting this reality.

  • Restore previous session often not available when reopen program

    About 1/2 the time when I reopen Firefox, the Restore Previous Session command is not available. I have to reconstruct my session from history, which is annoying and time consuming. Has anybody else had and solved this problem with a Mac?

    None of your possible conditions apply. I always use Quit to close. I've used the recently closed tabs and that only covers a few. I've had to search through History to restore tabs. I wasn't in Private Browsing Mode and I didn't Clear History on closing. Nice try, though. Thanks.

  • In printing only a specific selected section, the top line or 2 of the printout is not printing. This only happened since the last update. It does not happen when I use internet explorer.

    I read many financial documents during the day. I sometimes print only a selected segment of an article or a financial statement. When I print selected only, the top line or 2 lines is omitted from the print document. It does not happen in explorer.
    I used Firefox for years, and this just started in the last 3 weeks or so. I can get around it by just selecting 2 lines above what I want to print. But, it is annoying.

    * [[Printing a web page]]
    * [[Firefox prints incorrectly]]
    Check and tell if its working.

  • Buttons not working when implimented using Adobe Configurator

    Hi there, i recently learned about a new program called Adobe Configurator, which allows you to build your own custom panels for Photoshop. The program is brilliant, a brilliant idea, and all seems to work perfectly. However, its connection to Photoshop in only two buttons that i have tried to use, seems to fail.
    I set up two of my custom buttons to follow the path of "File > Share My Screen...", and the other to follow the path of "File > Device Central...". However, weather i have a document opened or not, these buttons never work. I get the error message saying "The command "Select" is not currently avalible.". It says this with other buttons, but only when there is nothing open, so it is understandable. So do these buttons just not work, or am i doing it wrong?
    Thanks.

    That's a limitation of many PDF readers on the iPad. They don't support interactivity well. There are a few that do. Here's a posting on InDesignSecrets.com that I did on the subject of differences between PDF readers:
    http://indesignsecrets.com/finding-the-best-tablet-pdf-reader.php
    My favorite is PDF Expert. However, I later found I had to outline the type if I used them in an InDesign-created button.

Maybe you are looking for

  • Help in reports..

    hi chetan, thanx for the solution. in my application when i am displying the report, i want to display comon columns as top headings. let me be little more clear. say it is like pass sheet given by bank. in the report my top line shud display a/c no,

  • Standard form for ECS in FI module.....?

    Hi all, Please provide if there is a standard form for Electronic clearing system(ECS) in FI and the corresponding print program... thanks

  • How to correctly use a fixed size thread pool?

    I am quite new to using concurrency in Java, so please forgive if this is a trivial question. I would like to make use of something like pool=Executors.newFixedThreadPool(n) to automatically use a fixed number of threads to process pieces of work. I

  • TS3297 I get a R6025 runtime error when signing in to itune

    I receive a R 6025 run time error when starting a search in I Tunes Store. I have downloaed the latest version of itunes.

  • Coloring of advanced list pane cells

    Is it possible to color ceels in Advanced List Pane (UI table)?