views:

543

answers:

2

We are tracking down some memory issues in our application and we have visibility into the size of our sessions where the problem seems to be. It is only affecting certain sessions where they seem to balloon out of control and we'd like to have the ability to invalidate those sessions more-or-less 'by hand' to reclaim that memory . Is there a way to do this through JMX? We are using JBoss 4.5.2 .

Thanks in advance.

+3  A: 

The answer is yes, you can.

--this gets the web module MBeans loaded in JBoss--

/opt/lib/jboss-4.2.3.GA/bin/twiddle.sh -s <--ServerIP-->:1099 query 'jboss.web:*' | grep "type=Manager"

--Once you have that you can get the active sessions from that MBean--

/opt/lib/jboss-4.2.3.GA/bin/twiddle.sh -s 172.16.0.216:1099 invoke "<--MBean-->" listSessionIds

--And finally, once you have that list, you can pick out the session of interest and expire it--

/opt/lib/jboss-4.2.3.GA/bin/twiddle.sh -s <--ServerIP-->:1099 invoke "<--MBean-->" expireSession <--SessionID-->

You would replace <--ServerIP--> with the ip the server is bound on...it need not be local. This can be run remotely as long as you have access to port 1099.

<--MBean--> would be replaced with one of the results of the first query.

<--SessionID--> would be replaced with one of the session ids from the second command.

Also you would replace /opt/lib/jboss-4.2.3.GA/bin/twiddle.sh with the location of twiddle on your machine. It is included in JBoss.

Ichorus
A: 

Thanks Ichorus. Your solution helped me with at least some way to see all the active sessions on the server at any given time.

Btw...Here are couple of things needed before running twiddle.sh Make sure JAVA_HOME and JBOSS_HOME are set in the environment And Make Sure JBOSS_CLASSPATH is either not set or has all the libs given in twiddle.sh.i.e {JBOSS_HOME}\client\jbossall-client.jar;{JBOSS_HOME}\client\getopt.jar;{JBOSS_HOME}\client\log4j.jar; {JBOSS_HOME}\lib\jboss-jmx.jar

Other wise you would run into ClassNotFound exceptions

Sudheer

Sudheer