Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Using remote JMX configuration from webapp .xml, not /etc/jetty-remote-jmx.xml

I am using Jetty 9.2.5. I have been following these instructions: http://www.eclipse.org/jetty/documentation/current/jmx-chapter.html

What I want to do, is have a jetty-jmx.xml file in my webapp, which is pointed to by the command-line used to start jetty.

Previously, in Jetty7, I had this argument: --pre=$JETTY_BASE/conf/jetty-jmx.xml

Now, in Jetty9, I still have this argument, and it comes before any other XML files in the invocation of Jetty. However, I notice that I get no remote JMX anything unless I have "--module=jmx-remote" in my start.ini (using an auxiliary start.ini, not modifying the jetty distribution's start.ini).

However, when I enable the jmx-remote module, the jetty distribution's /etc/jetty-jmx-remote.xml is loaded.

I don't want this. It doesn't have the correct path, and the path is not parameterized (/jmxrmi is used, but I want /jettyjmx). Additionally, I get an error at startup:

===========================
INFO   | jvm 1    | 2015/02/13 13:27:36 | 2015-02-13 13:27:36.075:WARN:oejx.XmlConfiguration:WrapperJarAppMain: Config error at <Call name="start"/> java.lang.reflect.InvocationTargetException in file:/usr/local/deploy/jetty-9.2.5/etc/jetty-jmx-remote.xml
INFO   | jvm 1    | 2015/02/13 13:27:36 | 2015-02-13 13:27:36.075:WARN:oejx.XmlConfiguration:WrapperJarAppMain: Config error at <New id="ConnectorServer" class="org.eclipse.jetty.jmx.ConnectorServer"><Arg>|      <New class="javax.management.remote.JMXServiceURL"><Arg type="java.lang.String">rmi</Arg><Arg type="java.lang.String"/><Arg type="java.lang.Integer"><SystemProperty name="jetty.jmxrmiport" default="1099"/></Arg><Arg type="java.lang.String">/jndi/rmi://<SystemProperty name="jetty.jmxrmihost" default="localhost"/>:<SystemProperty name="jetty.jmxrmiport" default="1099"/>/jmxrmi</Arg></New>|    </Arg><Arg>org.eclipse.jetty.jmx:name=rmiconnectorserver</Arg><Call name="start"/></New> java.lang.reflect.InvocationTargetException in file:/usr/local/deploy/jetty-9.2.5/etc/jetty-jmx-remote.xml
INFO   | jvm 1    | 2015/02/13 13:27:36 | java.lang.reflect.InvocationTargetException
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at java.lang.reflect.Method.invoke(Method.java:483)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.start.Main.invokeMain(Main.java:321)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.start.Main.start(Main.java:817)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.start.Main.main(Main.java:112)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at java.lang.reflect.Method.invoke(Method.java:483)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.tanukisoftware.wrapper.WrapperJarApp.run(WrapperJarApp.java:394)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at java.lang.Thread.run(Thread.java:745)
INFO   | jvm 1    | 2015/02/13 13:27:36 | Caused by: java.lang.reflect.InvocationTargetException
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at java.lang.reflect.Method.invoke(Method.java:483)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.util.TypeUtil.call(TypeUtil.java:500)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:730)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:417)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:815)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:423)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:354)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:262)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1243)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at java.security.AccessController.doPrivileged(Native Method)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     ... 13 more
INFO   | jvm 1    | 2015/02/13 13:27:36 | Caused by: java.io.IOException: Cannot bind to URL [rmi://10.28.120.226:4696/jmxrmi]: javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no such object in table]
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:827)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:432)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.jmx.ConnectorServer.doStart(ConnectorServer.java:109)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     ... 27 more
INFO   | jvm 1    | 2015/02/13 13:27:36 | Caused by: javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no such object in table]
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:147)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:228)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at javax.naming.InitialContext.bind(InitialContext.java:425)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:644)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:427)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     ... 29 more
INFO   | jvm 1    | 2015/02/13 13:27:36 | Caused by: java.rmi.NoSuchObjectException: no such object in table
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:379)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:141)
INFO   | jvm 1    | 2015/02/13 13:27:36 |     ... 33 more

===========================

The salient bit of that, I believe, is

=========
INFO   | jvm 1    | 2015/02/13 13:27:36 | Caused by: java.io.IOException: Cannot bind to URL [rmi://10.28.120.226:4696/jmxrmi]: javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no such object in table]
=========

"No such object in table."

In my webapp's jetty-jmx.xml, which is a combination of the work done in the jetty-distribution's /etc/jetty-jmx.xml and /etc/jetty-jmx-remote.xml, I have a section to create an RMI registry:

===========================
    <Call name="createRegistry" class="java.rmi.registry.LocateRegistry">
        <Arg type="java.lang.Integer"><SystemProperty name="com.sun.management.jmxremote.port" /></Arg>
        <Call name="sleep" class="java.lang.Thread">
            <Arg type="java.lang.Integer">1000</Arg>
        </Call>
    </Call>

===========================

It looks like this block doesn't have a counterpart in the jetty distribution's XML files. I suspect that jetty-jmx-remote.xml is failing with the "no such object in table" error either because the RMI registry hasn't been created yet, or because it's using the wrong url (I want a connecter at /jettyjmx, but the jetty distribution uses /jmxrmi).

I cannot test this unless I can figure out a way to prevent /etc/jetty-jmx-remote.xml from being loaded during jetty startup... or at least get my own jetty-jmx.xml to load first.

Here are my questions:

  1. When are jetty distribution XML files in /etc/*.xml loaded, relative to XML files specified on the command-line?
  2. Is there a way to prevent /etc/jetty-jmx-remote.xml from being loaded, while still keeping --module=jmx-remote in my start.jar?

I can customize my own start.ini, my own start.d, and I can customize the command-line used to start Jetty but it would be much more difficult for me to have to modify files in the jetty distribution.

I have attached my start.ini and my webapp's jetty-jmx.xml. My Jetty 9.2.5 distribution is unmodified.

Attachment: start.ini
Description: Binary data

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd";>

<!-- ============================================================================ -->
<!-- To correctly start Jetty with JMX module enabled, this configuration         -->
<!-- file must appear first in the list of the configuration files.               -->
<!-- The simplest way to achieve this is to add etc/jetty-jmx.xml as the          -->
<!-- first file in configuration file list at the end of start.ini file.          -->
<!-- ============================================================================ -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <!-- =========================================================== -->
    <!-- Initialize an mbean server                                  -->
    <!-- =========================================================== -->
    <Call id="MBeanServer" class="java.lang.management.ManagementFactory"
          name="getPlatformMBeanServer" />

    <!-- =========================================================== -->
    <!-- Initialize the Jetty MBean container                        -->
    <!-- =========================================================== -->
    <New id="MBeanContainer" class="org.eclipse.jetty.jmx.MBeanContainer">
        <Arg>
            <Ref id="MBeanServer" />
        </Arg>
    </New>

    <!-- Add to the Server to listen for object events -->
    <Get id="Container" name="container">
        <Call name="addEventListener">
            <Arg>
                <Ref id="MBeanContainer" />
            </Arg>
        </Call>
    </Get>

    <!-- Add to the Server as a lifecycle -->
    <!-- Only do this if you know you will only have a single jetty server -->
    <Call name="addBean">
        <Arg>
            <Ref id="MBeanContainer" />
        </Arg>
    </Call>

    <!-- Add the static log -->
    <Get id="Logger" class="org.eclipse.jetty.util.log.Log" name="log" />
    <Ref id="MBeanContainer">
        <Call name="addBean">
            <Arg>
                <Ref id="Logger" />
            </Arg>
        </Call>
    </Ref>

    <!-- In order to connect to the JMX server remotely from a different
        process, possibly running on a different host, Jetty JMX module
        can create a remote JMX connector. It requires RMI registry to
        be started prior to creating the connector server because the
        JMX specification uses RMI to facilitate connections.
    -->

    <!-- Optionally start the RMI registry. Normally RMI registry runs on
           port 1099. The argument below can be changed in order to comply
           with the firewall requirements.
-->

    <Call name="createRegistry" class="java.rmi.registry.LocateRegistry">
        <Arg type="java.lang.Integer"><SystemProperty name="com.sun.management.jmxremote.port" /></Arg>
        <Call name="sleep" class="java.lang.Thread">
            <Arg type="java.lang.Integer">1000</Arg>
        </Call>
    </Call>


    <!-- Optionally add a remote JMX connector. The parameters of the constructor
         below specify the JMX service URL, and the object name string for the
         connector server bean. The parameters of the JMXServiceURL constructor
         specify the protocol that clients will use to connect to the remote JMX
         connector (RMI), the hostname of the server (local hostname), port number
         (automatically assigned), and the URL path. Note that URL path contains
         the RMI registry hostname and port number, that may need to be modified
         in order to comply with the firewall requirements.
    -->

    <New id="ConnectorServer" class="org.eclipse.jetty.jmx.ConnectorServer">
        <Arg>
            <New class="javax.management.remote.JMXServiceURL">
                <Arg type="java.lang.String">rmi</Arg>
                <Arg type="java.lang.String" />
                <Arg type="java.lang.Integer">0</Arg>
                <Arg type="java.lang.String">/jndi/rmi://<SystemProperty name="com.svc.jmx.localhost" />:<SystemProperty name="com.sun.management.jmxremote.port" />/jettyjmx</Arg>
            </New>
        </Arg>
        <Arg>org.eclipse.jetty:name=rmiconnectorserver</Arg>
        <Call name="start" />
    </New>
</Configure>


Back to the top