java.rmi.ConnectException: Connexion refusée à host: 127.0.0.1

J'ai essayé d'utilisé RMI, ici, c'est côté serveur. au début, il a travaillé sans aucune exception, mais maintenant, après trois fois, à chaque fois que j'essaie d'exécuter le code ci-dessous, je vais obtenir quelques erreurs

Le code est:

import java.rmi.server.UnicastRemoteObject;

/**
 * Created by elyas on 12/11/14 AD.
 */
public class LogicImplement extends UnicastRemoteObject implements Logic
{

    public LogicImplement() throws Exception
    {
        java.rmi.registry.LocateRegistry.createRegistry(6060);
        java.rmi.Naming.rebind("Object1",this);
    }

    @Override
    public int sum(int a, int b) throws Exception
    {
        int result = a + b;
        System.out.println("ana sum executed");
        return result;
    }

    public static void main(String[] args)
    {
        try
        {
            LogicImplement logicImplement  = new LogicImplement();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    } 
} 

L'erreur est comme ça: j'ai essayé de changer l'Objet1, par exemple, Objet2, mais encore une fois j'obtiens le message d'erreur, j'ai modifier le numéro de port...

quelle est la solution?

java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:341)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:177)
at LogicImplement.<init>(LogicImplement.java:12)
at LogicImplement.main(LogicImplement.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 12 more

OriginalL'auteur Elyas Hadizadeh | 2014-12-11