[JMX] Problème avec MBeanServer
	
	
		Hello,
J'ai le code suivant:
	Code:
	
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
   | package jmx;
 
import java.io.IOException;
import java.util.HashMap;
 
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
 
import com.sun.jndi.rmi.registry.RegistryContextFactory;
 
 
public class NagiosBeanServer {
    //static JMXConnectorServer cs;
 
    public static void main(String[] argv){
 
        final String jmxRmiHost = "localhost";
 
        MBeanServerConnection connection = getConnection(jmxRmiHost);        
    }
    private static MBeanServerConnection getConnection(String jmxRmiHost) {
 
        final int rmiPort = 1099;
 
        JMXServiceURL url;
 
        try {
            url = new JMXServiceURL("service:jmx:rmi://" + jmxRmiHost + ":" + rmiPort + "/jndi/jrmp");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, RegistryContextFactory.class.getName());
 
        // add the security attributes if they are there
        HashMap theEnvironment = new HashMap();
 
        // Connect to the JMXRMI Adapter and get the MBeanServerConnection
        try {
            return JMXConnectorFactory.connect(url, theEnvironment).getMBeanServerConnection();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
} | 
 Si je le lance, j'obtient l'erreur suivante:
	Citation:
	
		
		
			java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is: 
    java.net.ConnectException: Connection refused]
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:323)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
    at jmx.NagiosBeanServer.getConnection(NagiosBeanServer.java:51)
    at jmx.NagiosBeanServer.main(NagiosBeanServer.java:28)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is: 
    java.net.ConnectException: Connection refused]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:107)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1871)
    at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1841)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
    ... 3 more
Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is: 
    java.net.ConnectException: Connection refused
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
    ... 8 more
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at java.net.Socket.<init>(Socket.java:366)
    at java.net.Socket.<init>(Socket.java:180)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
    ... 13 more
			
		
	
 sur la ligne : return JMXConnectorFactory.connect(url, theEnvironment).getMBeanServerConnection();
Quelqun sait pourquoi? Quelle est ma faute?
J'utilise java 6 sur Ubuntu 7.09...
Merci bcp d'avance, je suis vraiment bloqué... :cry:
A+