IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces Graphiques en Java Discussion :

Erreur "invalid URL String"


Sujet :

Interfaces Graphiques en Java

  1. #1
    Futur Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Décembre 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut Erreur "invalid URL String"
    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.

  2. #2
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 310
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 310
    Points : 9 522
    Points
    9 522
    Billets dans le blog
    1
    Par défaut
    Tu as un blanc entre "//" et "localhost"... retire-le...
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Futur Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Décembre 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Merci Obutterlin le problème du serveur est corrigé mais au début ça a marché mais après un autre problème se pose...

    En voulant exécuter mon code client l'erreur suivante m'apparait au console:
    java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
    java.net.ConnectException: Connection refused: connect
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    at sun.rmi.server.UnicastRef.newCall(Unknown Source)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at java.rmi.Naming.lookup(Unknown Source)
    at nnn.ChatClient.<init>(ChatClient.java:24)
    at nnn.ChatClient.main(ChatClient.java:87)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
    ... 8 more
    java.lang.NullPointerException
    at nnn.ChatClient$1.actionPerformed(ChatClient.java:51)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Quelqu'un saurait-il m'indiquer pourquoi la connexion à localhost est refusée ?

    Pourtant ça a fonctionné au début...

    Merci d'avance

  4. #4
    Membre actif
    Homme Profil pro
    Développeur Java/JavaEE
    Inscrit en
    Août 2014
    Messages
    194
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur Java/JavaEE

    Informations forums :
    Inscription : Août 2014
    Messages : 194
    Points : 290
    Points
    290
    Par défaut
    Bonjour,


    at java.rmi.Naming.lookup(Unknown Source)
    at nnn.ChatClient.<init>(ChatClient.java:24)
    at nnn.ChatClient.main(ChatClient.java:87)
    Caused by: java.net.ConnectException: Connection refused: connect
    Je pense que tu dois vérifier tes paramètres de lookup pour consommer tes RMI.

Discussions similaires

  1. [MySQL] Supprimer les erreurs de syntaxe dues aux quotes
    Par gotenks dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 25/01/2006, 16h10
  2. Réponses: 6
    Dernier message: 21/10/2005, 18h59
  3. Oracle 7 -> Oracle 8 : "Invalid Row Id"
    Par gmartintin dans le forum Bases de données
    Réponses: 4
    Dernier message: 20/10/2004, 11h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo