last week,i find memcached-session-manager can help me to store
session in memcached.so i had a try.

i use spring-mvc as my web controler.

when the customer login on the web i did this:

----------------------------------------------------------------------------------------
User loginUser = userService.dealLogin(user);
System.out.println("sessionId: "+request.getSession().getId());
HttpSession session = request.getSession();
session.setAttribute(Constant.CURRENT_USER, loginUser);
System.out.println("user:
"+session.getAttribute(Constant.CURRENT_USER));

---------------------------------------------------------------------------------------------------------------------

from now on,the session is ok and i can get the attirbute
"Constant.CURRENT_USER".

But then i send another request,the request was catched by zhe
springmvc‘s interceptor(i use it for authfilter).

------------------------------------
System.out.println("sessionId: "+sesion.getId());
System.out.println("user:
"+sesion.getAttribute(Constant.CURRENT_USER));
---------------------------------------------------

i get the session and the sessionId equal the first sessionId.

but i get the attribute Constant.CURRENT_USER,it return null ~ !

this is why?somebody who can help me !

Search Discussions

  • Martin Grotzke at Dec 26, 2011 at 7:04 am
    Please provide details regarding the configuration. Are there any warnings
    in the logs? Is the user object serializable?

    Cheers,
    Martin

    Am 26.12.2011 07:56 schrieb "miwucc" <xxlforest@gmail.com>:
    last week,i find memcached-session-manager can help me to store
    session in memcached.so i had a try.

    i use spring-mvc as my web controler.

    when the customer login on the web i did this:


    ----------------------------------------------------------------------------------------
    User loginUser = userService.dealLogin(user);
    System.out.println("sessionId: "+request.getSession().getId());
    HttpSession session = request.getSession();
    session.setAttribute(Constant.CURRENT_USER, loginUser);
    System.out.println("user:
    "+session.getAttribute(Constant.CURRENT_USER));


    ---------------------------------------------------------------------------------------------------------------------

    from now on,the session is ok and i can get the attirbute
    "Constant.CURRENT_USER".

    But then i send another request,the request was catched by zhe
    springmvc‘s interceptor(i use it for authfilter).

    ------------------------------------
    System.out.println("sessionId: "+sesion.getId());
    System.out.println("user:
    "+sesion.getAttribute(Constant.CURRENT_USER));
    ---------------------------------------------------

    i get the session and the sessionId equal the first sessionId.

    but i get the attribute Constant.CURRENT_USER,it return null ~ !

    this is why?somebody who can help me !
  • Miwucc at Dec 26, 2011 at 7:28 am
    this is my tomcat option:

    in the context.xml is:

    <Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat
    restarts -->
    <!--
    <Manager pathname="" />
    -->
    <!-- -->
    <Manager
    className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
    memcachedNodes="n1:localhost:11211"
    requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
    sessionBackupAsync="false"
    sticky="true"
    sessionBackupTimeout="100"

    transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
    copyCollectionsForSerialization="false"
    />


    <!-- Uncomment this to enable Comet connection tacking (provides
    events
    on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve
    className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

    </Context>

    i did a whalin memcached java client and get the session by sessionId
    as key but throwe exception:

    58 MemCachedClient mcc = new MemCachedClient();
    59 MemcachedItem item = mcc.gets("166066000F3726BC85FFE8426F978AF8-
    n1.tomcat1");
    60 HttpSession session = (HttpSession)item.getValue();
    61 System.out.println("sessionID: "+session.getId());
    62 System.out.println("current_user:
    "+session.getAttribute("current_user"));


    83 [main] ERROR com.danga.MemCached.MemCachedClient - ++++ exception
    thrown while trying to get object from cache for key:
    166066000F3726BC85FFE8426F978AF8-n1.tomcat1
    114 [main] ERROR com.danga.MemCached.MemCachedClient - Value out of
    range. Value:"2048" Radix:10
    java.lang.NumberFormatException: Value out of range. Value:"2048"
    Radix:10
    at java.lang.Byte.parseByte(Byte.java:153)
    at java.lang.Byte.parseByte(Byte.java:108)
    at com.schooner.MemCached.AscIIClient.gets(AscIIClient.java:881)
    at com.schooner.MemCached.AscIIClient.gets(AscIIClient.java:638)
    at com.schooner.MemCached.AscIIClient.gets(AscIIClient.java:634)
    at com.danga.MemCached.MemCachedClient.gets(MemCachedClient.java:
    1087)
    at Test2.main(Test2.java:59)
    Exception in thread "main" java.lang.NullPointerException
    at Test2.main(Test2.java:60)










    On 12月26日, 下午3时04分, Martin Grotzke wrote:
    Please provide details regarding the configuration. Are there any warnings
    in the logs? Is the user object serializable?

    Cheers,
    Martin

    Am 26.12.2011 07:56 schrieb "miwucc" <xxlfor...@gmail.com>:






    last week,i find memcached-session-manager can help me to store
    session in memcached.so i had a try.
    i use spring-mvc as my web controler.
    when the customer login on the web i did this:
    --------------------------------------------------------------------------- -------------
    User loginUser = userService.dealLogin(user);
    System.out.println("sessionId: "+request.getSession().getId());
    HttpSession session = request.getSession();
    session.setAttribute(Constant.CURRENT_USER, loginUser);
    System.out.println("user:
    "+session.getAttribute(Constant.CURRENT_USER));
    --------------------------------------------------------------------------- ------------------------------------------
    from now on,the session is ok and i can get the attirbute
    "Constant.CURRENT_USER".
    But then i send another request,the request was catched by zhe
    springmvc‘s interceptor(i use it for authfilter).
    ------------------------------------
    System.out.println("sessionId: "+sesion.getId());
    System.out.println("user:
    "+sesion.getAttribute(Constant.CURRENT_USER));
    ---------------------------------------------------
    i get the session and the sessionId equal the first sessionId.
    but i get the attribute Constant.CURRENT_USER,it return null ~ !
    this is why?somebody who can help me !
  • Miwucc at Dec 26, 2011 at 7:34 am
    the jar i set in tomcat's lib folder is :

    javolution-5.4.3.1.jar
    memcached-2.4.2.jar
    msm-javolution-serializer-cglib-1.3.0.jar
    msm-javolution-serializer-jodatime-1.3.0.jar
    memcached-session-manager-1.3.0.jar

    On 12月26日, 下午3时04分, Martin Grotzke wrote:
    Please provide details regarding the configuration. Are there any warnings
    in the logs? Is the user object serializable?

    Cheers,
    Martin

    Am 26.12.2011 07:56 schrieb "miwucc" <xxlfor...@gmail.com>:






    last week,i find memcached-session-manager can help me to store
    session in memcached.so i had a try.
    i use spring-mvc as my web controler.
    when the customer login on the web i did this:
    --------------------------------------------------------------------------- -------------
    User loginUser = userService.dealLogin(user);
    System.out.println("sessionId: "+request.getSession().getId());
    HttpSession session = request.getSession();
    session.setAttribute(Constant.CURRENT_USER, loginUser);
    System.out.println("user:
    "+session.getAttribute(Constant.CURRENT_USER));
    --------------------------------------------------------------------------- ------------------------------------------
    from now on,the session is ok and i can get the attirbute
    "Constant.CURRENT_USER".
    But then i send another request,the request was catched by zhe
    springmvc‘s interceptor(i use it for authfilter).
    ------------------------------------
    System.out.println("sessionId: "+sesion.getId());
    System.out.println("user:
    "+sesion.getAttribute(Constant.CURRENT_USER));
    ---------------------------------------------------
    i get the session and the sessionId equal the first sessionId.
    but i get the attribute Constant.CURRENT_USER,it return null ~ !
    this is why?somebody who can help me !
  • Miwucc at Dec 26, 2011 at 7:59 am
    it is ok now. my use a old config. i read the wiki again and config
    is.it works now.thank you very much Martin Grotzke
    On 12月26日, 下午3时04分, Martin Grotzke wrote:
    Please provide details regarding the configuration. Are there any warnings
    in the logs? Is the user object serializable?

    Cheers,
    Martin

    Am 26.12.2011 07:56 schrieb "miwucc" <xxlfor...@gmail.com>:






    last week,i find memcached-session-manager can help me to store
    session in memcached.so i had a try.
    i use spring-mvc as my web controler.
    when the customer login on the web i did this:
    --------------------------------------------------------------------------- -------------
    User loginUser = userService.dealLogin(user);
    System.out.println("sessionId: "+request.getSession().getId());
    HttpSession session = request.getSession();
    session.setAttribute(Constant.CURRENT_USER, loginUser);
    System.out.println("user:
    "+session.getAttribute(Constant.CURRENT_USER));
    --------------------------------------------------------------------------- ------------------------------------------
    from now on,the session is ok and i can get the attirbute
    "Constant.CURRENT_USER".
    But then i send another request,the request was catched by zhe
    springmvc‘s interceptor(i use it for authfilter).
    ------------------------------------
    System.out.println("sessionId: "+sesion.getId());
    System.out.println("user:
    "+sesion.getAttribute(Constant.CURRENT_USER));
    ---------------------------------------------------
    i get the session and the sessionId equal the first sessionId.
    but i get the attribute Constant.CURRENT_USER,it return null ~ !
    this is why?somebody who can help me !
  • Martin Grotzke at Dec 26, 2011 at 8:19 am
    Ok, great it's working for you now.

    Btw, you cannot load the session from memcached, only msm can do this as it
    knows how to deserialize it (no standard object serialization due to some
    optimizations). So you must only use the servlet api.

    Another hint: if you want to get the best performance you should use the
    kryo transcoder.

    Cheers,
    Martin

    Am 26.12.2011 08:59 schrieb "miwucc" <xxlforest@gmail.com>:
    it is ok now. my use a old config. i read the wiki again and config
    is.it works now.thank you very much Martin Grotzke
    On 12月26日, 下午3时04分, Martin Grotzke wrote:
    Please provide details regarding the configuration. Are there any warnings
    in the logs? Is the user object serializable?

    Cheers,
    Martin

    Am 26.12.2011 07:56 schrieb "miwucc" <xxlfor...@gmail.com>:






    last week,i find memcached-session-manager can help me to store
    session in memcached.so i had a try.
    i use spring-mvc as my web controler.
    when the customer login on the web i did this:
    ---------------------------------------------------------------------------
    -------------
    User loginUser = userService.dealLogin(user);
    System.out.println("sessionId: "+request.getSession().getId());
    HttpSession session = request.getSession();
    session.setAttribute(Constant.CURRENT_USER, loginUser);
    System.out.println("user:
    "+session.getAttribute(Constant.CURRENT_USER));
    ---------------------------------------------------------------------------
    ------------------------------------------
    from now on,the session is ok and i can get the attirbute
    "Constant.CURRENT_USER".
    But then i send another request,the request was catched by zhe
    springmvc‘s interceptor(i use it for authfilter).
    ------------------------------------
    System.out.println("sessionId: "+sesion.getId());
    System.out.println("user:
    "+sesion.getAttribute(Constant.CURRENT_USER));
    ---------------------------------------------------
    i get the session and the sessionId equal the first sessionId.
    but i get the attribute Constant.CURRENT_USER,it return null ~ !
    this is why?somebody who can help me !

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmemcached-session-manager @
categoriesmemcached
postedDec 26, '11 at 6:57a
activeDec 26, '11 at 8:19a
posts6
users2
websitememcached.org

2 users in discussion

Miwucc: 4 posts Martin Grotzke: 2 posts

People

Translate

site design / logo © 2022 Grokbase