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
> >> >
> >> >
> >>
> >
> >
>