Session Expiration using MBeans - Weblogic

This is a discussion on Session Expiration using MBeans - Weblogic ; Guys, Am having hung sessions in memory i.e sessions are not expiring even after setting time out period of 30 minutes in web.xml and weblogic.xml file, wondering if anyone knows how to kill them programatically using MBeans. In other words ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: Session Expiration using MBeans

  1. Session Expiration using MBeans


    Guys,
    Am having hung sessions in memory i.e sessions are not expiring even after
    setting time out period of 30 minutes in web.xml and weblogic.xml file, wondering
    if anyone knows how to kill them programatically using MBeans. In other words
    is there a MBean class which gives me list of all active sessions in memory ?

    Thanks

  2. Re: Session Expiration using MBeans

    Session expiration should work fine. We are not aware of any known issues in
    this area. Checkout session.getMaxInactiveInterval to make sure the value
    you have specified in weblogic.xml has taken effect.

    --Vinod.


    "Randheer Gehlot" wrote in message
    news:406c1f48$1@newsgroups.bea.com...
    >
    > Guys,
    > Am having hung sessions in memory i.e sessions are not expiring

    even after
    > setting time out period of 30 minutes in web.xml and weblogic.xml file,

    wondering
    > if anyone knows how to kill them programatically using MBeans. In other

    words
    > is there a MBean class which gives me list of all active sessions in

    memory ?
    >
    > Thanks




  3. Re: Session Expiration using MBeans


    Vinod,
    The MaxInActiveInterval is set and is OK, if there was any issues with
    that none of the sessions will expire, but in my case about 10% of total session
    do not expire they just stay in memory, do you know of any MBeans that I can use
    to kill these hung sessions programatically ... or if you have any other programatic
    suggestions...have done everything with settings in both the deployment descriptor
    files but some sessions still stay active, Any more suggestions/ advise.

    "Vinod Mehra" wrote:
    >Session expiration should work fine. We are not aware of any known issues
    >in
    >this area. Checkout session.getMaxInactiveInterval to make sure the value
    >you have specified in weblogic.xml has taken effect.
    >
    >--Vinod.
    >
    >
    >"Randheer Gehlot" wrote in message
    >news:406c1f48$1@newsgroups.bea.com...
    >>
    >> Guys,
    >> Am having hung sessions in memory i.e sessions are not expiring

    >even after
    >> setting time out period of 30 minutes in web.xml and weblogic.xml file,

    >wondering
    >> if anyone knows how to kill them programatically using MBeans. In other

    >words
    >> is there a MBean class which gives me list of all active sessions in

    >memory ?
    >>
    >> Thanks

    >
    >



  4. Re: Session Expiration using MBeans

    If you have session monitoring turned on ...

    weblogic.xml:


    false


    .... then you should be able to lookup the runtime mbean
    (ServletSessionRuntimeMBean) for the session and call invalidate on it.

    Anyway, sessions not getting invalidated is not good! Instead of trying to
    working around it I would encourage you to open a support case with a
    reproducer.

    Also you might want to use SessionLifetimeListeners to debug this problem.
    BTW, how do you figure out that the session has not expired? Can you access
    it's values?

    Another thought, are using custom ELF logger? If so there is a known issue
    which matches your problem description. If this is indeed the case you might
    want to ask support for the patch for CR136735.

    --Vinod.

    "Randheer Gehlot" wrote in message
    news:406c7cc7$1@newsgroups.bea.com...
    >
    > Vinod,
    > The MaxInActiveInterval is set and is OK, if there was any issues

    with
    > that none of the sessions will expire, but in my case about 10% of total

    session
    > do not expire they just stay in memory, do you know of any MBeans that I

    can use
    > to kill these hung sessions programatically ... or if you have any other

    programatic
    > suggestions...have done everything with settings in both the deployment

    descriptor
    > files but some sessions still stay active, Any more suggestions/ advise.
    >
    > "Vinod Mehra" wrote:
    > >Session expiration should work fine. We are not aware of any known issues
    > >in
    > >this area. Checkout session.getMaxInactiveInterval to make sure the value
    > >you have specified in weblogic.xml has taken effect.
    > >
    > >--Vinod.
    > >
    > >
    > >"Randheer Gehlot" wrote in message
    > >news:406c1f48$1@newsgroups.bea.com...
    > >>
    > >> Guys,
    > >> Am having hung sessions in memory i.e sessions are not expiring

    > >even after
    > >> setting time out period of 30 minutes in web.xml and weblogic.xml file,

    > >wondering
    > >> if anyone knows how to kill them programatically using MBeans. In other

    > >words
    > >> is there a MBean class which gives me list of all active sessions in

    > >memory ?
    > >>
    > >> Thanks

    > >
    > >

    >




  5. Re: Session Expiration using MBeans


    Vinod,
    Could you please throw some more light on "cutom ELF logger", what does
    ELF stand for ? I'm indeed using apache logger library/jar to log error messages
    to a file.
    I have "Session Monitoring" turned on and that gives me information of open seesions.
    I will try to open up a case with BEA support....but if you have any more thoughts
    on debugging/ resolving this issue , please let me knwo.

    Thank you
    "Vinod Mehra" wrote:
    >If you have session monitoring turned on ...
    >
    >weblogic.xml:
    >
    >
    > false
    >

    >
    >... then you should be able to lookup the runtime mbean
    >(ServletSessionRuntimeMBean) for the session and call invalidate on it.
    >
    >Anyway, sessions not getting invalidated is not good! Instead of trying
    >to
    >working around it I would encourage you to open a support case with a
    >reproducer.
    >
    >Also you might want to use SessionLifetimeListeners to debug this problem.
    >BTW, how do you figure out that the session has not expired? Can you
    >access
    >it's values?
    >
    >Another thought, are using custom ELF logger? If so there is a known
    >issue
    >which matches your problem description. If this is indeed the case you
    >might
    >want to ask support for the patch for CR136735.
    >
    >--Vinod.
    >
    >"Randheer Gehlot" wrote in message
    >news:406c7cc7$1@newsgroups.bea.com...
    >>
    >> Vinod,
    >> The MaxInActiveInterval is set and is OK, if there was any

    >issues
    >with
    >> that none of the sessions will expire, but in my case about 10% of

    >total
    >session
    >> do not expire they just stay in memory, do you know of any MBeans that

    >I
    >can use
    >> to kill these hung sessions programatically ... or if you have any

    >other
    >programatic
    >> suggestions...have done everything with settings in both the deployment

    >descriptor
    >> files but some sessions still stay active, Any more suggestions/ advise.
    >>
    >> "Vinod Mehra" wrote:
    >> >Session expiration should work fine. We are not aware of any known

    >issues
    >> >in
    >> >this area. Checkout session.getMaxInactiveInterval to make sure the

    >value
    >> >you have specified in weblogic.xml has taken effect.
    >> >
    >> >--Vinod.
    >> >
    >> >
    >> >"Randheer Gehlot" wrote in message
    >> >news:406c1f48$1@newsgroups.bea.com...
    >> >>
    >> >> Guys,
    >> >> Am having hung sessions in memory i.e sessions are not expiring
    >> >even after
    >> >> setting time out period of 30 minutes in web.xml and weblogic.xml

    >file,
    >> >wondering
    >> >> if anyone knows how to kill them programatically using MBeans. In

    >other
    >> >words
    >> >> is there a MBean class which gives me list of all active sessions

    >in
    >> >memory ?
    >> >>
    >> >> Thanks
    >> >
    >> >

    >>

    >
    >



  6. Re: Session Expiration using MBeans


    Vinod,
    One more thing am using IFRAMES in some of my pages ? Would that cause
    a problem ?

    Thanks...
    "Vinod Mehra" wrote:
    >If you have session monitoring turned on ...
    >
    >weblogic.xml:
    >
    >
    > false
    >

    >
    >... then you should be able to lookup the runtime mbean
    >(ServletSessionRuntimeMBean) for the session and call invalidate on it.
    >
    >Anyway, sessions not getting invalidated is not good! Instead of trying
    >to
    >working around it I would encourage you to open a support case with a
    >reproducer.
    >
    >Also you might want to use SessionLifetimeListeners to debug this problem.
    >BTW, how do you figure out that the session has not expired? Can you
    >access
    >it's values?
    >
    >Another thought, are using custom ELF logger? If so there is a known
    >issue
    >which matches your problem description. If this is indeed the case you
    >might
    >want to ask support for the patch for CR136735.
    >
    >--Vinod.
    >
    >"Randheer Gehlot" wrote in message
    >news:406c7cc7$1@newsgroups.bea.com...
    >>
    >> Vinod,
    >> The MaxInActiveInterval is set and is OK, if there was any

    >issues
    >with
    >> that none of the sessions will expire, but in my case about 10% of

    >total
    >session
    >> do not expire they just stay in memory, do you know of any MBeans that

    >I
    >can use
    >> to kill these hung sessions programatically ... or if you have any

    >other
    >programatic
    >> suggestions...have done everything with settings in both the deployment

    >descriptor
    >> files but some sessions still stay active, Any more suggestions/ advise.
    >>
    >> "Vinod Mehra" wrote:
    >> >Session expiration should work fine. We are not aware of any known

    >issues
    >> >in
    >> >this area. Checkout session.getMaxInactiveInterval to make sure the

    >value
    >> >you have specified in weblogic.xml has taken effect.
    >> >
    >> >--Vinod.
    >> >
    >> >
    >> >"Randheer Gehlot" wrote in message
    >> >news:406c1f48$1@newsgroups.bea.com...
    >> >>
    >> >> Guys,
    >> >> Am having hung sessions in memory i.e sessions are not expiring
    >> >even after
    >> >> setting time out period of 30 minutes in web.xml and weblogic.xml

    >file,
    >> >wondering
    >> >> if anyone knows how to kill them programatically using MBeans. In

    >other
    >> >words
    >> >> is there a MBean class which gives me list of all active sessions

    >in
    >> >memory ?
    >> >>
    >> >> Thanks
    >> >
    >> >

    >>

    >
    >



  7. Re: Session Expiration using MBeans


    I tried ServletSessionRuntimeMBean, but this gives me only the current session,
    am looking for MBean that has LIST of all session in memory so that I can loop
    through them and if I find any invalid/timeout session I would like to kill it.
    DO you know of any MBean class that will give me LIST of all the active sessions
    ?

    Thanks
    "Vinod Mehra" wrote:
    >If you have session monitoring turned on ...
    >
    >weblogic.xml:
    >
    >
    > false
    >

    >
    >... then you should be able to lookup the runtime mbean
    >(ServletSessionRuntimeMBean) for the session and call invalidate on it.
    >
    >Anyway, sessions not getting invalidated is not good! Instead of trying
    >to
    >working around it I would encourage you to open a support case with a
    >reproducer.
    >
    >Also you might want to use SessionLifetimeListeners to debug this problem.
    >BTW, how do you figure out that the session has not expired? Can you
    >access
    >it's values?
    >
    >Another thought, are using custom ELF logger? If so there is a known
    >issue
    >which matches your problem description. If this is indeed the case you
    >might
    >want to ask support for the patch for CR136735.
    >
    >--Vinod.
    >
    >"Randheer Gehlot" wrote in message
    >news:406c7cc7$1@newsgroups.bea.com...
    >>
    >> Vinod,
    >> The MaxInActiveInterval is set and is OK, if there was any

    >issues
    >with
    >> that none of the sessions will expire, but in my case about 10% of

    >total
    >session
    >> do not expire they just stay in memory, do you know of any MBeans that

    >I
    >can use
    >> to kill these hung sessions programatically ... or if you have any

    >other
    >programatic
    >> suggestions...have done everything with settings in both the deployment

    >descriptor
    >> files but some sessions still stay active, Any more suggestions/ advise.
    >>
    >> "Vinod Mehra" wrote:
    >> >Session expiration should work fine. We are not aware of any known

    >issues
    >> >in
    >> >this area. Checkout session.getMaxInactiveInterval to make sure the

    >value
    >> >you have specified in weblogic.xml has taken effect.
    >> >
    >> >--Vinod.
    >> >
    >> >
    >> >"Randheer Gehlot" wrote in message
    >> >news:406c1f48$1@newsgroups.bea.com...
    >> >>
    >> >> Guys,
    >> >> Am having hung sessions in memory i.e sessions are not expiring
    >> >even after
    >> >> setting time out period of 30 minutes in web.xml and weblogic.xml

    >file,
    >> >wondering
    >> >> if anyone knows how to kill them programatically using MBeans. In

    >other
    >> >words
    >> >> is there a MBean class which gives me list of all active sessions

    >in
    >> >memory ?
    >> >>
    >> >> Thanks
    >> >
    >> >

    >>

    >
    >



  8. Re: Session Expiration using MBeans

    Here is a jsp to give you an idea. Unfortunately the session timeout
    (max-inactive-interval) is not exposed in the runtime mbean. So you will
    have to hardcode it for now. If you want it be exposed please ask support
    for a patch.

    <%@ page import="weblogic.management.runtime.ServletSessionRuntimeM Bean,
    weblogic.management.MBeanHome,
    weblogic.management.Admin,
    java.util.Date,
    java.util.Set,
    java.util.Iterator,
    weblogic.servlet.security.ServletAuthentication,
    weblogic.management.runtime.WebAppComponentRuntime MBean" %>

    <%!
    private static final long TIME_OUT = 10; // seconds
    %>
    <%
    // login as system user
    // FIXME: don't hardcode username/passwords
    ServletAuthentication.weak("system", "gumby1234", request, response);

    MBeanHome home = Admin.getInstance().getMBeanHome();
    if (home != null) {
    Set mbeanSet = home.getMBeansByType("ServletSessionRuntime");
    Iterator mbeanIterator = null;
    mbeanIterator = mbeanSet.iterator();
    while (mbeanIterator.hasNext()) {
    ServletSessionRuntimeMBean runtime =
    (ServletSessionRuntimeMBean)mbeanIterator.next();
    WebAppComponentRuntimeMBean parent = (WebAppComponentRuntimeMBean)
    runtime.getParent();
    out.print("ContextPath: " + parent.getContextRoot() +
    " LastAccessedTime: " + new Date(runtime.getTimeLastAccessed()));
    if (hasSessionExpired(runtime)) {
    out.println(" Invalidating expired session!!");
    runtime.invalidate();
    } else {
    out.println(" Session is still good");
    }
    }
    }
    %>
    <%!
    private boolean hasSessionExpired(ServletSessionRuntimeMBean runtime) {
    return (runtime.getTimeLastAccessed() < (System.currentTimeMillis() -
    TIME_OUT * 1000));
    }
    %>

    hth,
    Vinod.


    "Randheer Gehlot" wrote in message
    news:406da8dd$1@newsgroups.bea.com...
    >
    > I tried ServletSessionRuntimeMBean, but this gives me only the current

    session,
    > am looking for MBean that has LIST of all session in memory so that I can

    loop
    > through them and if I find any invalid/timeout session I would like to

    kill it.
    > DO you know of any MBean class that will give me LIST of all the active

    sessions
    > ?
    >
    > Thanks
    > "Vinod Mehra" wrote:
    > >If you have session monitoring turned on ...
    > >
    > >weblogic.xml:
    > >
    > >
    > > false
    > >

    > >
    > >... then you should be able to lookup the runtime mbean
    > >(ServletSessionRuntimeMBean) for the session and call invalidate on it.
    > >
    > >Anyway, sessions not getting invalidated is not good! Instead of trying
    > >to
    > >working around it I would encourage you to open a support case with a
    > >reproducer.
    > >
    > >Also you might want to use SessionLifetimeListeners to debug this

    problem.
    > >BTW, how do you figure out that the session has not expired? Can you
    > >access
    > >it's values?
    > >
    > >Another thought, are using custom ELF logger? If so there is a known
    > >issue
    > >which matches your problem description. If this is indeed the case you
    > >might
    > >want to ask support for the patch for CR136735.
    > >
    > >--Vinod.
    > >
    > >"Randheer Gehlot" wrote in message
    > >news:406c7cc7$1@newsgroups.bea.com...
    > >>
    > >> Vinod,
    > >> The MaxInActiveInterval is set and is OK, if there was any

    > >issues
    > >with
    > >> that none of the sessions will expire, but in my case about 10% of

    > >total
    > >session
    > >> do not expire they just stay in memory, do you know of any MBeans that

    > >I
    > >can use
    > >> to kill these hung sessions programatically ... or if you have any

    > >other
    > >programatic
    > >> suggestions...have done everything with settings in both the deployment

    > >descriptor
    > >> files but some sessions still stay active, Any more suggestions/

    advise.
    > >>
    > >> "Vinod Mehra" wrote:
    > >> >Session expiration should work fine. We are not aware of any known

    > >issues
    > >> >in
    > >> >this area. Checkout session.getMaxInactiveInterval to make sure the

    > >value
    > >> >you have specified in weblogic.xml has taken effect.
    > >> >
    > >> >--Vinod.
    > >> >
    > >> >
    > >> >"Randheer Gehlot" wrote in message
    > >> >news:406c1f48$1@newsgroups.bea.com...
    > >> >>
    > >> >> Guys,
    > >> >> Am having hung sessions in memory i.e sessions are not

    expiring
    > >> >even after
    > >> >> setting time out period of 30 minutes in web.xml and weblogic.xml

    > >file,
    > >> >wondering
    > >> >> if anyone knows how to kill them programatically using MBeans. In

    > >other
    > >> >words
    > >> >> is there a MBean class which gives me list of all active sessions

    > >in
    > >> >memory ?
    > >> >>
    > >> >> Thanks
    > >> >
    > >> >
    > >>

    > >
    > >

    >




  9. Re: Session Expiration using MBeans


    vinod,
    Thanks, Boy you rock !!! am now able to delete hung sessions, but am
    still not sure about the cause of the problem, while looking at access.log file
    the other day I noticed that WLS is not deleting sessions when somebody is trying
    to log in and at the same time somebody else is running a report(concurrent requests).....
    we just have one servlet in a our application so all the requests goes to it....
    am thinking it could be a threading issue ? Do you have any inputs on that, I
    dont think my servlet is Thread safe, I will change it to be thread safe.....
    also are there any settings in WLS that I need to look into ?

    "Vinod Mehra" wrote:
    >Here is a jsp to give you an idea. Unfortunately the session timeout
    >(max-inactive-interval) is not exposed in the runtime mbean. So you will
    >have to hardcode it for now. If you want it be exposed please ask support
    >for a patch.
    >
    ><%@ page import="weblogic.management.runtime.ServletSessionRuntimeM Bean,
    > weblogic.management.MBeanHome,
    > weblogic.management.Admin,
    > java.util.Date,
    > java.util.Set,
    > java.util.Iterator,
    > weblogic.servlet.security.ServletAuthentication,
    > weblogic.management.runtime.WebAppComponentRuntime MBean"
    >%>
    >

    ><%!
    > private static final long TIME_OUT = 10; // seconds
    >%>
    ><%
    > // login as system user
    > // FIXME: don't hardcode username/passwords
    > ServletAuthentication.weak("system", "gumby1234", request, response);
    >
    > MBeanHome home = Admin.getInstance().getMBeanHome();
    > if (home != null) {
    > Set mbeanSet = home.getMBeansByType("ServletSessionRuntime");
    > Iterator mbeanIterator = null;
    > mbeanIterator = mbeanSet.iterator();
    > while (mbeanIterator.hasNext()) {
    > ServletSessionRuntimeMBean runtime =
    >(ServletSessionRuntimeMBean)mbeanIterator.next();
    > WebAppComponentRuntimeMBean parent = (WebAppComponentRuntimeMBean)
    >runtime.getParent();
    > out.print("ContextPath: " + parent.getContextRoot() +
    > " LastAccessedTime: " + new Date(runtime.getTimeLastAccessed()));
    > if (hasSessionExpired(runtime)) {
    > out.println(" Invalidating expired session!!");
    > runtime.invalidate();
    > } else {
    > out.println(" Session is still good");
    > }
    > }
    > }
    >%>
    ><%!
    > private boolean hasSessionExpired(ServletSessionRuntimeMBean runtime)
    >{
    > return (runtime.getTimeLastAccessed() < (System.currentTimeMillis()
    >-
    >TIME_OUT * 1000));
    > }
    >%>
    >
    >hth,
    >Vinod.
    >
    >
    >"Randheer Gehlot" wrote in message
    >news:406da8dd$1@newsgroups.bea.com...
    >>
    >> I tried ServletSessionRuntimeMBean, but this gives me only the current

    >session,
    >> am looking for MBean that has LIST of all session in memory so that

    >I can
    >loop
    >> through them and if I find any invalid/timeout session I would like

    >to
    >kill it.
    >> DO you know of any MBean class that will give me LIST of all the active

    >sessions
    >> ?
    >>
    >> Thanks
    >> "Vinod Mehra" wrote:
    >> >If you have session monitoring turned on ...
    >> >
    >> >weblogic.xml:
    >> >
    >> >
    >> > false
    >> >

    >> >
    >> >... then you should be able to lookup the runtime mbean
    >> >(ServletSessionRuntimeMBean) for the session and call invalidate on

    >it.
    >> >
    >> >Anyway, sessions not getting invalidated is not good! Instead of trying
    >> >to
    >> >working around it I would encourage you to open a support case with

    >a
    >> >reproducer.
    >> >
    >> >Also you might want to use SessionLifetimeListeners to debug this

    >problem.
    >> >BTW, how do you figure out that the session has not expired? Can

    >you
    >> >access
    >> >it's values?
    >> >
    >> >Another thought, are using custom ELF logger? If so there is a known
    >> >issue
    >> >which matches your problem description. If this is indeed the case

    >you
    >> >might
    >> >want to ask support for the patch for CR136735.
    >> >
    >> >--Vinod.
    >> >
    >> >"Randheer Gehlot" wrote in message
    >> >news:406c7cc7$1@newsgroups.bea.com...
    >> >>
    >> >> Vinod,
    >> >> The MaxInActiveInterval is set and is OK, if there was

    >any
    >> >issues
    >> >with
    >> >> that none of the sessions will expire, but in my case about 10%

    >of
    >> >total
    >> >session
    >> >> do not expire they just stay in memory, do you know of any MBeans

    >that
    >> >I
    >> >can use
    >> >> to kill these hung sessions programatically ... or if you have any
    >> >other
    >> >programatic
    >> >> suggestions...have done everything with settings in both the deployment
    >> >descriptor
    >> >> files but some sessions still stay active, Any more suggestions/

    >advise.
    >> >>
    >> >> "Vinod Mehra" wrote:
    >> >> >Session expiration should work fine. We are not aware of any known
    >> >issues
    >> >> >in
    >> >> >this area. Checkout session.getMaxInactiveInterval to make sure

    >the
    >> >value
    >> >> >you have specified in weblogic.xml has taken effect.
    >> >> >
    >> >> >--Vinod.
    >> >> >
    >> >> >
    >> >> >"Randheer Gehlot" wrote in message
    >> >> >news:406c1f48$1@newsgroups.bea.com...
    >> >> >>
    >> >> >> Guys,
    >> >> >> Am having hung sessions in memory i.e sessions are not

    >expiring
    >> >> >even after
    >> >> >> setting time out period of 30 minutes in web.xml and weblogic.xml
    >> >file,
    >> >> >wondering
    >> >> >> if anyone knows how to kill them programatically using MBeans.

    >In
    >> >other
    >> >> >words
    >> >> >> is there a MBean class which gives me list of all active sessions
    >> >in
    >> >> >memory ?
    >> >> >>
    >> >> >> Thanks
    >> >> >
    >> >> >
    >> >>
    >> >
    >> >

    >>

    >
    >



+ Reply to Thread