Bonjour,
j'essaye de faire un petit programme de gestion de bank en java RMI
j'ai quelque problemes vu que je n'arrive pas a compilé avec rmic (comme le plus part des sites le disent)
ça c'est le main de ma classe BanqueImpl que j'ai reussi a faire marché en lançant
le rmiregistry depuis l'arborescence de mon projet sur le port 5000
ensuite quand j'essaye de lancer le client, ça marche mais au moment du lookup ça coince
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 public static void main(String[] args) { // Étape 1 : installation du gestionnaire de sécurité System.setSecurityManager(new RMISecurityManager()); try { // Étape optionelle : Lancement du registre //java.rmi.registry.LocateRegistry.createRegistry(1099); // Étape 2 : instanciation de lobjet réparti BanqueImpl Monserveur = new BanqueImpl(); // Étape 3 : enregistrement auprès du registre java.rmi.Naming.rebind("rmi://localhost:5000/Gestioin", Monserveur); } // fin try catch (Exception e) { e.printStackTrace();} } // fin Main }
et voila l'exception
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
62
63
64
65
66 public static void main(String[] args) { int choix=0; System.out.println("100 pour arreter"); while(choix!=100) try { System.out.println("Choisissez l'operation a effectuer"); System.out.println("1- Creer un nouveau Compte"); System.out.println("2 - Ajouter de l'argent"); System.out.println("3 - Retirer de l'argent "); System.out.println("4 - Info sur Client "); BufferedReader fluxClavier = new BufferedReader( new InputStreamReader(System.in)); String s = fluxClavier.readLine(); choix = new Integer(s).intValue(); // Récupération du stub System.out.println("Binding...."); Gestion obj =(Gestion)java.rmi.Naming.lookup ("rmi://localhost:5000/Gestion"); // Appel dune méthode sur lobjet distant if (choix ==1){ System.out.println("numero ID"); s = fluxClavier.readLine(); int id = new Integer(s).intValue(); System.out.println("Somme initiale"); s = fluxClavier.readLine(); double somme_initiale = new Integer(s).intValue(); obj.creer_compte(id, somme_initiale); } else if(choix ==2){ System.out.println("numero ID"); s = fluxClavier.readLine(); int id = new Integer(s).intValue(); System.out.println("Somme"); s = fluxClavier.readLine(); double somme = new Integer(s).intValue(); obj.ajouter(id, somme); } else if(choix ==3){ System.out.println("numero ID"); s = fluxClavier.readLine(); int id = new Integer(s).intValue(); System.out.println("Somme"); s = fluxClavier.readLine(); double somme = new Integer(s).intValue(); obj.retirer(id, somme); }else if(choix ==4){ System.out.println("numero ID"); s = fluxClavier.readLine(); int id = new Integer(s).intValue(); Position p1 = obj.position(id); System.out.println("numero ID"+p1.getIdentifiant());; System.out.println("solde "+p1.getSolde());; System.out.println("date"+p1.getDerniereOperation());; } //String msg=obj.repete("coucou2"); //System.out.println("Reponse du serveur : "+msg); } // fin try catch (Exception e) {e.printStackTrace();} }
et Gestion est juste une interface qui etends java.rmi.Remote
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 4 - Info sur Client 2 Binding.... java.rmi.NotBoundException: Gestion at sun.rmi.registry.RegistryImpl.lookup(Unknown Source) at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source) at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source) at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at sun.rmi.transport.Transport$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source) at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at java.rmi.Naming.lookup(Unknown Source) at BanqueClient.main(BanqueClient.java:30)
ps : ma jre est une 1.6 et suis sous Windows
Voila si quelqu"un à plus d'experience en RMI ou peut m'orienter sur le probléme
Merci
Tarek
Partager