Skip to content

Instantly share code, notes, and snippets.

@james-carr
Created December 20, 2011 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save james-carr/1503624 to your computer and use it in GitHub Desktop.
Save james-carr/1503624 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<Configure class="org.mortbay.jetty.Server">
<!-- =========================================================== -->
<!-- Initialize an mbean server -->
<!-- =========================================================== -->
<!-- Use the jdk 1.5 platformMBeanServer -->
<Call id="MBeanServer" class="java.lang.management.ManagementFactory" name="getPlatformMBeanServer"/>
<!-- =========================================================== -->
<!-- Initialize the Jetty MBean container -->
<!-- =========================================================== -->
<Get id="Container" name="container">
<Call name="addEventListener">
<Arg>
<New class="org.mortbay.management.MBeanContainer">
<Arg><Ref id="MBeanServer"/></Arg>
<!-- If using < jdk1.5 uncomment to start http adaptor -->
<!-- Set name="managementPort">8082</Set -->
<Call name="start" />
</New>
</Arg>
</Call>
</Get>
<!--
When setting up the JMXConnectorServer via RMI, two TCP ports are used to communicate with
the remote server:
* the rmiregistry port (by default 1099) from where the RMI stub is downloaded
* the rmi server port (by default randomly chosen) where the actual RMI communication happens
The JMXServiceURL for the default configuration is therefore:
service:jmx:rmi:///jndi/rmi://<remotehost>:1099/jmxrmi
In case a firewall is restricting port access, you need to make sure that the rmi server port
is not chosen randomly, and this can be specified with the following JMXServiceURL:
service:jmx:rmi://<host>:2100/jndi/rmi://<host>:2099/jmxrmi
where 2099 is the rmiregistry port and 2100 is the rmi server port.
Make sure the firewall allow access to those ports.
When using the XML configuration below, you don't need to specify any of the JMX system properties
on the command line (see http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html).
-->
<!-- Setup the RMIRegistry on a specific port-->
<Call id="rmiRegistry" class="java.rmi.registry.LocateRegistry" name="createRegistry">
<Arg type="int">2099</Arg>
</Call>
<!-- Setup the JMXConnectorServer on a specific rmi server port-->
<Call id="jmxConnectorServer" class="javax.management.remote.JMXConnectorServerFactory" name="newJMXConnectorServer">
<Arg>
<New class="javax.management.remote.JMXServiceURL">
<Arg>service:jmx:rmi://localhost:2100/jndi/rmi://localhost:2099/jmxrmi</Arg>
</New>
</Arg>
<Arg/>
<Arg><Ref id="MBeanServer"/></Arg>
<Call name="start"/>
</Call>
</Configure>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment