Bonjour,

J'ai développe une application de chat en ligne mais un problème relatif à l'URL du serveur m’empêche de poursuivre mon travail.

Voici l'erreur qui m'apparait:
ChatServer err: invalid URL String: // localhost/ChatServer,
java.net.MalformedURLException: invalid URL String: // localhost/ChatServer,
at java.rmi.Naming.parseURL(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at nnn.ChatServerImp.main(ChatServerImp.java:54)
Caused by: java.net.URISyntaxException: Illegal character in authority at index 2: // localhost/ChatServer,
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.parseAuthority(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
at java.rmi.Naming.intParseURL(Unknown Source)
... 3 more
et ceci est le code de l'implémentation de mon serveur (c'est là ou se trouve le problème), ce Unknown source là ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
  Naming.rebind("// localhost/ChatServer,", thisExample );
Comment le nom du serveur doit-il être choisi exactement ? J'ai cherché plusieurs solutions mais vainement...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
53
54
55
56
57
58
59
60
61
package nnn;
 
import java.net.MalformedURLException;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.util.*;
 
public class ChatServerImp extends UnicastRemoteObject
    implements ChatServer {
 
  Vector chatListeners = new Vector();
 
  public ChatServerImp() throws RemoteException {
  }
 
  public void addChatListener(ChatListener cl)
      throws java.rmi.RemoteException {
    System.out.println("Adding Listener");
    chatListeners.add(cl);
  }
 
  public void removeChatListener(ChatListener cl)
      throws java.rmi.RemoteException {
    System.out.println("Removing Listener");
    chatListeners.remove(cl);
  }
 
  public void sendChatMessage(String message)
      throws java.rmi.RemoteException {
    Vector v;
    synchronized(this) {v = (Vector)chatListeners.clone();}
 
  try {
      int i=0;
 
     while (i<10){
 
     for (Enumeration e = v.elements(); e.hasMoreElements();) {
      ChatListener cl = (ChatListener)e.nextElement();
      cl.chatEventSent(new ChatEvent(this, message));
      i++;
    }
     }
  }
   catch(Exception e) {
    e.printStackTrace();
  }
  }
 
  public static void main(String argv[]) throws MalformedURLException{
    try {
      ChatServerImp thisExample = new ChatServerImp();
 
      Naming.rebind("// localhost/ChatServer,", thisExample );
    } catch (Exception e) {
       System.out.println("ChatServer err: "+ e.getMessage());
 
       e.printStackTrace();
    }
  }
}
Quelqu'un saurait-il m'indiquer comment corriger ce problème ?

Merci d'avance pour votre aide.