[CORBA / LDAP] Erreur "ava.net.MalformedURLException: Not an LDAP URL"
Bonjour,
J'ai essaye de développer une application client / serveur d'un annuaire de personnes.
Voici mon fichier jndi.properties
Code:
1 2
| java.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
java.naming.provider.url=iiop://localhost:9000 |
Le code du serveur :
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
| public class ProjerServer {
public static void main(String[] args) {
try{
//Créer et initialiser l'ORB
ORB orb=ORB.init(args,null);
// Récupérer et activer le POAManager
POA rootpao =POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpao.the_POAManager().activate();
//Créer un servant et l'enregistrer avec l'ORB
repertoireImp repert=new repertoireImp();
// Context ctx=new InitialContext();
//ctx.rebind("repertoire",rootpao.servant_to_reference(repert));
repert.setORB(orb);
orb.run();
// référencer le servant par le POA
Object ref=rootpao.servant_to_reference(repert);
IRepertoirecorba href=IRepertoirecorbaHelper.narrow((org.omg.CORBA.Object) ref);
// Récupérer le service de nommage et créer un nom
Object objRef=orb.resolve_initial_references("NameService");
//(narrow) convertion des objets CORBA en java
NamingContextExt ncRef=NamingContextExtHelper.narrow((org.omg.CORBA.Object) objRef);
//Lier le servant au service de nommage
NameComponent path[]=ncRef.to_name("Repertoire");
//Enregistrement du Servant avec le Name Server
ncRef.rebind(path,href);
System.out.println("Le serveur est en attente...");
// Attendre les invocations par des clients
orb.run();
} catch (Exception e){
System.err.println("Error: "+e);
e.printStackTrace(System.out);
}
} |
Client :
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
| public class client{
public static void main(String[] args) throws ExisteDeja, Inconnu {
Object ref = null;
// initialiser l'orb
/*ORB orb=ORB.init(args,null);
//Récupérer le service de nommage
org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService");
NamingContextExt ncRef=NamingContextExtHelper.narrow(objRef);
IRepertoirecorba obj=IRepertoirecorbaHelper.narrow(ncRef.resolve_str("service"));*/
try{
Properties namingProperties = new Properties();
namingProperties.put (Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
namingProperties.put (Context.PROVIDER_URL, "iiop://localhost:900");
InitialContext ctx=new InitialContext(namingProperties);
ref=ctx.lookup("client_repertoire/Client");
}catch(NamingException e){
System.err.println("erreur "+e);
}
IRepertoirecorba obj=IRepertoirecorbaHelper.narrow((org.omg.CORBA.Object)ref);
Scanner lecture=new Scanner(System.in);
System.out.println("Entrer le nom de personne ");
String nom=lecture.next();
System.out.println("Entrer le prenom de personne "); |
Lorsque je lance le serveur aucune erreur ne s’affiche. En revanche, lorsque je lance le client j'ai l'erreur :
Citation:
javax.naming.NamingException: Cannot parse url: iiop://localhost:900 [Root exception is java.net.MalformedURLException: Not an LDAP URL: iiop://localhost:900]
Entrer le nom de personne
et il continue l'exécution.
Quelqu'un saurait-il m'indiquer comment résoudre ce problème ?
Merci d'avance pour votre aide.