开发者

Howto use custom JMXAuthenticator

I have to authenticate JMX clients against entries in a database. Therefore I have written a custom JMXAuthenticator implementation.

When starting up my application I can access the MBeans using JConsole via the 'Local Process'. But when I try to access it as a remote process using the url 'service:jmx:rmi:///jndi/rmi://localhost:10999/jmxrmi' JConsole shows a message complaining that 'The connection to service:jmx:rmi:///jndi/rmi://localhost:10999/jmxrmi did not succeed.'

Below is the server side code to start up the MBeanServer and the JMXConnectorServer. Has anybody an idea what I am doing wrong?

Thanks in advance,

Thomas

final MBeanServer mbs = MBeanServerFactory.createMBeanServer("MyDomain");
final HashMap<String, Object> environment = new HashMap<String, Object>();
final JMXAuthenticator authenticator = new JMXAuthenticatorImpl();
environment.put(JMXConnectorServer.AUTHENTICATOR, authenticator);

final JMXServiceURL serviceURL = new J开发者_开发技巧MXServiceURL("rmi", "localhost", 10999);

final JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, environment, mbs);

connectorServer.start();


It seems the problem was that I have not created the RMI Registry before creating the new JMXConnectorServer.

Inserting

LocateRegistry.createRegistry(port);

before creating the JMXConnectorServer solved the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜