Community
Participate
Working Groups
Build Identifier: I've tried to set the named property in the very beginning of jetty-jmx.xml like this: <Call class="java.lang.System" name="setProperty"> <Arg>java.rmi.server.hostname</Arg> <Arg>10.111.1.122</Arg> </Call> However it doesn't seem to have any effect. Setting the same property on the CMDL just works fine. Cheers, Thomas Reproducible: Always
Created attachment 206962 [details] proposed patch Patchfile for a commented call to set the property in jetty-jmx.xml. Please do not commit until we made sure this works.
Thomas, Many java properties cannot be set inside the application, as that is too late in the start up cycle. So we have the start.ini file in $JETTY_HOME. You can uncomment the line "--exec" to force jetty to start a new jvm, and then any of the lines below it that are uncommented will be passed as args to the new jvm. I suggest you try putting -Djava.rmi.server.hostname=127.0.0.1 into start.ini instead. Should work. Jan
After I've successfully tested this with a very simple Main class: public static void main(String[] args) throws MalformedURLException, IOException, InterruptedException { MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); LocateRegistry.createRegistry(1099); Thread.sleep(1000); JMXConnectorServer jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL("service:jmx:rmi://localhost:1099/jndi/rmi://localhost:1099/jettyjmx"),null,mBeanServer); System.out.println(System.setProperty("java.rmi.server.hostname","192.168.33.33")); jmxConnectorServer.start(); System.out.println(jmxConnectorServer.toJMXConnector(null)); System.out.println(System.getProperty("java.rmi.server.hostname")); jmxConnectorServer.stop(); } Emulates the behaviour in jetty-jmx.xml, makes sure that the system property is not set before by printing the previous value to stdout, sets the property just before JMXConnectorServer is created and returns the values to stdout. This proofs that setting the property will work fine as long as it is set before JMXConnectorServer is connected as we expected it. So I messed around with jetty-jmx.xml and tried the following: <Call id="JMXConnectorServer" name="newJMXConnectorServer" class="javax.management.remote.JMXConnectorServerFactory"> <Arg> <New class="javax.management.remote.JMXServiceURL"> <Arg type="java.lang.String">service:jmx:rmi://localhost:1099/jndi/rmi://localhost:1099/jettyjmx</Arg> </New> </Arg> <Arg /> <Arg><Ref id="MBeanServer" /></Arg> <Call name="start" /> <Call id="JMXConnector" name="toJMXConnector"> <Arg/> </Call> </Call> <Ref id="MBeanServer"> <Call name="registerMBean"> <Arg><Ref id="JMXConnectorServer" /></Arg> <Arg> <New class="javax.management.ObjectName"> <Arg>org.eclipse.jetty.jmx:name=rmiconnectorserver</Arg> </New> </Arg> </Call> </Ref> <Get class="java.lang.System" name="out"> <Call name="println"> <Arg type="java.lang.String"> <Ref id="JMXConnector"/> </Arg> </Call> </Get> Which worked fine immediately as well. So I've done a quick network trace to make sure that even with this setup the ip set by the config pasted in my first post is returned in the rmi connection negotiation. And it is. I'm a bit clueless why the exact same config on the test system we've tried this yesterday still didn't work. The server was started properly with the exact same config and no errors have been written during startup. Really weird. Guess we can close this as it just works out of the box on my local box.
Just for the record. I've done the same test with the jetty config above with a broken /etc/hosts entry and on a remote server. Setting the property via jetty xml works just fine. Still curious why it didn't work on the test server though. Please feel free to submit my patch and close the issue.
Committed. Jan