2012-09-03 73 views
0

訪問JBoss 5.1.0.GA的mebeans時出現以下錯誤。如何在訪問JBoss 5.1.0.GA的mbeans時解決「javax.management.InstanceNotFoundException」?

 Exception in thread "main" javax.management.InstanceNotFoundException: jboss.system:type=ServerInfo 
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094) 
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:662) 
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:638) 
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1404) 
at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72) 
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1265) 
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1360) 
at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:600) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305) 
at sun.rmi.transport.Transport$1.run(Transport.java:159) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.rmi.transport.Transport.serviceCall(Transport.java:155) 
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) 
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) 
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) 
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
at java.lang.Thread.run(Thread.java:662) 
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255) 
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233) 
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142) 
at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source) 
at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source) 
at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(RMIConnector.java:878) 
at test.mbean.JBossJMXClient.main(JBossJMXClient.java:30) 

這是我的java類;

public class JBossJMXClient { 
    public static void main(String[] args) throws Exception { 
     String host = "192.168.0.249";// Your JBoss Bind Address default is 
            // localhost 
    int port = 4545; // management-native port 
     String urlString = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port 
      + "/jmxrmi"; 
     System.out.println("  \n\n\t**** urlString: " + urlString); 
    JMXServiceURL serviceURL = new JMXServiceURL(urlString); 
    JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, 
      null); 
    MBeanServerConnection connection = jmxConnector 
      .getMBeanServerConnection(); 

    // Invoke on the JBoss AS MBean server 
    int count = connection.getMBeanCount(); 
    System.out.println(count); 
    ObjectName objectName = new ObjectName("jboss.system:type=ServerInfo"); 
    String javaVersion = (String)connection.getAttribute(objectName, "JavaVersion"); 
    System.out.println(javaVersion); 
    jmxConnector.close(); 
    } 
    } 

我已經ckecked firewall.It沒有problem.How來解決這個問題?

回答

0

嘗試使用RMI默認端口:1090.的確,在URL中做一些更改;

String urlString = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxconnector"; 

查看url的最後部分:從「jmxrmi」到「jmxconnector」。

相關問題