title: Number of Active Sessions in Tomcat
body: <p>I have my web services jar file deployed under <code>webapps\nyx\WEB-INF\services</code> in my tomcat server. Now I am trying to get no of active sessions using below code inside a web service method.</p>
  
  <pre><code>MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
  ObjectName objectName = new ObjectName("Catalina:type=Manager,context=/nyx/services,host=localhost");
  Object activeSessions =mBeanServer.getAttribute(objectName,"activeSessions");
  </code></pre>
  
  <p>But this gives me <strong>Instance not found</strong> exception.<br>
  Can someone help me with the value for the context attribute?</p>