JMX和Jconsole

08-09-02 windgoogle
import java.rmi.registry.*;

import javax.management.*;

import javax.management.remote.*;

public class JmxServer {

public JmxServer() {

start();

}

public void start(){

try{

MBeanServer jmxServer;

if( MBeanServerFactory.findMBeanServer(null).size() > 0 ) {

jmxServer=(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);

} else {

jmxServer=MBeanServerFactory.createMBeanServer("TongWeb");

}

jmxServer.registerMBean(new Monitor(),new ObjectName("tongtech.tw:systemMonitor=huangfeng"));

System.out.println("******jmx server started************");

}catch(Exception ex){

ex.printStackTrace();

}

}

}

public class JMXTest {

public JMXTest() {

}

public static void main(String args []){

JmxServer jmxserver=new JmxServer();

}

}

为什么用java -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote

.authenticate=false JMXTest 启动后,用jconsole用9999端口连接不上了,这段代码跟tomcat(创建MBServer)里的差不多,tomcat为什么可以连接呢,百思不得其解

banq
2008-09-02 20:21
java缺省是封闭安全的,建议从授权安全方面去检查。

猜你喜欢