Zum Inhalt springen

kamoi08

Mitglieder
  • Gesamte Inhalte

    4
  • Benutzer seit

  • Letzter Besuch

Alle Inhalte von kamoi08

  1. kamoi08

    Java RMI

    Welche Frage denn?
  2. kamoi08

    Java RMI

    Schon geschaft, keine Antworten mehr nötig.
  3. kamoi08

    Java RMI

    Und was muss ich tun damit sie gefunden wird?
  4. kamoi08

    Java RMI

    Hey! Ich habe wie man sich sicher denken kanne in Problem mit einem RMI-Callback Testprogramm. Ich glaube, dass mein Quellcode soweit richtig ist und ich nur probleme mit der policy habe, aber ich bin mir nicht sicher. Hier der Quellcode von meinem Minibeispiel. Client: // Client import java.io.Serializable; import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.NotBoundException; import java.rmi.RMISecurityManager; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class Client implements ClientInterface, Serializable { private static final long serialVersionUID = 4099187184648337776L; public ServerInterface server; public static Client c; public Client() { super(); if(System.getSecurityManager() == null){ System.setSecurityManager(new RMISecurityManager()); } try { System.out.println("Client gestartet!"); UnicastRemoteObject.exportObject(this, 0); } catch (Exception e) { e.printStackTrace(); } } public void setGeaendert() throws RemoteException { try { System.out.println("Neuer Text!: " + server.getText()); } catch (RemoteException e) { e.printStackTrace(); } } public static void main(String[] args) { c = new Client(); try { c.server = (ServerInterface) Naming.lookup("server"); c.server.reg((ClientInterface) c); c.server.setAnders("Geändert?"); } catch (RemoteException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (NotBoundException e) { e.printStackTrace(); } } } ClientInterface: // ClientInterface import java.rmi.Remote; import java.rmi.RemoteException; public interface ClientInterface extends Remote { public void setGeaendert() throws RemoteException; } Server: // Server import java.rmi.Naming; import java.rmi.RMISecurityManager; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; public class Server extends UnicastRemoteObject implements ServerInterface { private static final long serialVersionUID = 4273340694886491827L; public String s = "unverändert!"; public ClientInterface c; public Server() throws RemoteException { super(); if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); System.err.println(System.getSecurityManager()); } } public void setAnders(String s) throws RemoteException { this.s = s; if (c != null) c.setGeaendert(); } public String getText() throws RemoteException { return s; } public void reg(ClientInterface c) throws RemoteException { this.c = c; } public static void main(String[] args) { try { Server s = new Server(); LocateRegistry.createRegistry(Registry.REGISTRY_PORT); Naming.rebind("server", s); System.out.println("Server hochgefahren!"); } catch (Exception e) { e.printStackTrace(); } } } ServerInterface: import java.rmi.Remote; import java.rmi.RemoteException; public interface ServerInterface extends Remote { public void setAnders(String s) throws RemoteException; public String getText() throws RemoteException; public void reg(ClientInterface c) throws RemoteException; } Und zuguterletzt meine Policy: grant { permission java.net.SocketPermission "*:1024-65535", "connect,accept,resolve"; permission java.security.AllPermission "",""; }; Wenn ich den Server starten möchte bekomme ich folgenden Fehler: Exception in thread "main" java.lang.NoClassDefFoundError: Server Caused by: java.lang.ClassNotFoundException: Server at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Could not find the main class: Server. Program will exit. Wer weiß wo mein Fehler liegt? Danke schon mal :confused:

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...