|
#1
|
|||
|
|||
|
Hope someone can help.
What I'd like to do is list tomcat sessions and destroy them, if required, in my Spring web-app and am stuck. I've switched JMX remoteing (not that I think I need it) on using JVM params and have found the tomcat management bean that does what I require in JConsole. My question is: How do I configure and use this MBean in Spring? I tried this: Code:
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"> <property name="locateExistingServerIfPossible" value="true"></property> </bean> <bean id="sessionProxy" class="org.springframework.jmx.access.MBeanProxyFactoryBean"> <property name="objectName" value="Catalina:type=Manager,path=/ep4,host=localhost"/> <property name="proxyInterface" value="javax.management.modelmbean.ModelMBean"/> <property name="server" ref="mbeanServer"/> </bean> Code:
org.springframework.jmx.access.InvalidInvocationException: Attribute 'MBeanInfo' is not exposed on the management interface If the answer is RTFM; which M do I Fing R. Thanks |
|
#2
|
|||
|
|||
|
Find out which interfaces the specific bean implements. Spring tries to call the getMBeanInfo method (that is specified on the interface) but apparently that isn't implemented by the underlying class.
__________________
Marten Deinum
Blog Use the [ code ] tags, young padawan |
|
#3
|
|||
|
|||
|
...as JConsole told me the MBean's class was an org.apache.commons.modeler.BaseModelMBean which implements
javax.management.modelmbean.ModelMBean (amongst others) which includes the getMBeanInfo() method. DEBUG logging org.springframework.jmx doesn't give me any clues either. I have definitely missed something - Thanks anyway |
|
#4
|
|||
|
|||
|
Was barking up the wrong tree on this one. Was an easy fix in the end.
Added a jmxServices bean: Code:
<bean id="jmxServices" class="com.globalfilings.services.JMXServices"> <property name="managerName" value="Catalina:type=Manager,path=/ep4,host=localhost"/> <property name="server" ref="mbeanServer"/> </bean> Code:
public List getSessionIds() {
List sessionList = null;
try {
ObjectName contextObjectName = new ObjectName(getManagerName());
String olist = (String)server.invoke(contextObjectName, "listSessionIds", null, null);
sessionList = new ArrayList(Arrays.asList(olist.split(" ")));
} catch (Exception e) {
log.error(e);
}
return sessionList;
}
Code:
public void expireSession(String sessionId){
ObjectName contextObjectName;
try {
contextObjectName = new ObjectName(getManagerName());
server.invoke(contextObjectName, "expireSession", new String[]{sessionId}, new String[]{"java.lang.String"});
} catch (Exception e) {
log.error(e);
}
}
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|