From Resin 3.0

Jump to: navigation, search

<document> <header> <product>resin</product> <title>JMX Consoles</title> <description>

JMX Consoles provide access to both the MBean's that Resin publishes for information about and control of the Resin server and Application specific MBeans.

</description> </header>

<body> <summary localtoc="true"/>

<s1 title="JDK 5.0 and JMX">

JDK 5.0 includes a JMX implementation that is used to provide local and remote administration of a Resin server.

<example title="Start Resin and allow local JMX administration"> win> ./resin.exe unix> bin/ </example>

<example title="Start jconsole"> win> jconsole.exe unix> jconsole

Choose Resin's JVM from the "Local" list. </example>

<example title="Start Resin and allow remote JMX administration"> win> ./resin.exe unix> bin/ </example>

Without some configuration effort, the previous command will not work. Password configuration and SSL configuration is required by the JDK implementation of remote JMX. Detailed instructions are included in the JDK documentation.

The following is useful for testing, but should be done with caution as the port is not protected by password or by SSL, and if not protected by a firewall is accessible by anyone who can guess the port number.

<example title="Start Resin and remote JMX - disable password checking and SSL">

win> ./resin.exe


unix> bin/ \



<example title="Start jconsole"> win> jconsole.exe unix> jconsole

Enter the host name and port number (9999) on the "Remote" tab </example>

<example title="Setting a password for remote JMX access"> $ cd $JAVA_HOME/jre/lib/management $ cp jmxremote.password.template jmxremote.password $ chmod u=rw jmxremote.password $ vi jmxremote.password

Set a password for "monitorRole" and "controlRole":

monitorRole 12monitor controlRole 55control </example>

<example title="Start Resin and remote JMX - disable SSL">

win> ./resin.exe


unix> bin/ \



<example title="Start jconsole"> win> jconsole.exe unix> jconsole </example>

Enter the host name and port number (9999) on the "Remote" tab Enter the username and password on the "Remote" tab


</body> </document>

<document> <header> <product>resin</product> <title>Instrumenting Resources</title> <description>

The facilities of JMX are a convenient way to provide an administration interface to objects and components in web applications.

</description> </header>

<body> <summary/>

<s1 title="Instrumenting Resources">

Instrumenting resources so JMX can manage them consists of the following steps:

  1. For a class MyFoo, create an interface MyFooMBean with the management interface.
  2. Class MyFoo needs to implement the MyFooMBean interface.
  3. Register MyFoo with the JMX server.

<s2 title="Instrumenting a servlet">

Resin will automatically register any servlet which implement an MBean interface. By default, the JMX name will be:

<def> web-app:j2eeType=Servlet,name=servlet-name </def>

<deftable title="ObjectName attributes"> <tr><th>Attribute</th><th>Value </th></tr><tr><td>j2eeType</td><td>Servlet </td></tr><tr><td>WebModule</td><td>the contextPath </td></tr><tr><td>J2EEApplication</td><td>the host? </td></tr><tr><td>J2EEServer</td><td>the server-id? </td></tr></deftable>

The domain is web-app, the type property is javax.servlet.Servlet and the name property is the value of <servlet-name>.

JMX clients will use the name to manage the servlet. For example, a client might use the pattern web-app:type=javax.servlet.Servlet,* to retrieve all managed servlets.

<example title=""> package test;

public interface MyServletMBean {

 public int getCount();

} </example>

<example title=""> package test;

import*; import javax.servlet.*;

public class MyServlet extends GenericServlet implements MyServletMBean {

 private int count;
 public int getCount()
   return count;
 public void service(ServletRequest request,
                     ServletResponse response)
   throws IOException
   PrintWriter out = response.getWriter();
   out.println("Hello, world");

} </example>



<s1 title="Managing Resources">

Managing resources uses the JMX API, primarily using the MBeanServer object. In Resin, each web-app has its own MBeanServer.

<example title="Getting the Count attribute"> import*;


MBeanServer server = MBeanServerFactory.createMBeanServer();

ObjectName name = new ObjectName("web-app:j2eeType=javax.servlet.Servlet," +


Object value = server.getAttribute(name, "Count");

out.println("Count: " + value); </example>

<s2 title="/resin-status">

The <a href="doc|jmx|servlet">resin-status servlet</a> has a primitive generic JMX management view of JMX managed servlets. By adding a MBean interface to your servlet, you'll automatically get a view of your servlets from /resin-status.






   <title>Information Servlet /resin-status </title>

Resin provides a primitive status servlet /resin-status. It's disabled by default to avoid any security issues.


<s1 title="Configure the /resin-status servlet">

<example title="resin.xml /resin-status configuration"> <resin xmlns=""




     <servlet-mapping servlet-class='com.caucho.servlets.ResinStatusServlet'>
       <init enable="read"/>
       <web-resource-collection url-pattern="/resin-status/*"/>



</example> </s1>

<s1 title="Interpreting the proxy cache hit ratio">

The proxy cache is Resin's internal proxy cache (in Resin Pro). The hit ratio marks what percentage of requests are served out of the cache, i.e. quickly, and which percentage are taking the full time.

The proxy cache hit ratio is useful for seeing if you can improve your application's performance with better caching. For example, if you had a news site like, you should have a high hit rate to make sure you're not overtaxing the database.

If you have a low value, you might want to look at your heavily used pages to see if you can cache more.

</s1> </body> </document>

Personal tools