hehe_me
Mitglied
hi,
ich erhalte folgende fehlermeldung beim starten des Servers:
mein code sieht so aus:
ServerInfo.java
Server.java
Client.java
der code sollte stimmen.. hab es auch mal zum laufen gebracht nur scheint es des öfteren nicht zu gehen.. sourcecode technisch versteh ich das nur verstehe nicht warum diese fehlermeldungen erscheinen...
ich erhalte folgende fehlermeldung beim starten des Servers:
Code:
Exception in thread "main" java.rmi.ServerException: RemoteException occurred in
server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: rmi1.ServerInfo
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:5
35)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTranspor
t.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:907)
at java.lang.Thread.run(Thread.java:619)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at rmi1.Server.main(Server.java:19)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
ception is:
java.lang.ClassNotFoundException: rmi1.ServerInfo
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:5
35)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTranspor
t.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:907)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: rmi1.ServerInfo
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:7
11)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:655)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:592)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:6
28)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294
)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStrea
m.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
... 12 more
mein code sieht so aus:
ServerInfo.java
Code:
package rmi1;
import java.rmi.*;
public interface ServerInfo extends Remote
{
String getServerIp() throws RemoteException;
String getServerName() throws RemoteException;
}
Server.java
Code:
package rmi1;
import java.net.InetAddress;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class Server implements ServerInfo{
private final InetAddress a;
public static void main(String[] args) throws Exception
{
Server s = new Server();
ServerInfo stub = (ServerInfo)UnicastRemoteObject.exportObject(s,0);
Registry registry = LocateRegistry.getRegistry();
registry.bind("ServerInfo", stub);
System.out.println("Server läuft.");
}
public Server() throws Exception
{
a = InetAddress.getLocalHost();
}
public String getServerIp()
{
return a.getHostAddress();
}
public String getServerName()
{
return a.getHostName();
}
}
Client.java
Code:
package rmi1;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
public static void main(String[] args) throws Exception
{
Registry registry = LocateRegistry.getRegistry("127.0.0.1");
String[] services = registry.list();
for(int i=0; i<services.length; i++)
System.out.println("Service gefunden: " + services[i]);
ServerInfo stub = (ServerInfo)registry.lookup("ServerInfo");
System.out.println("Server IP: " + stub.getServerIp());
System.out.println("Server Name: " + stub.getServerName());
}
}
der code sollte stimmen.. hab es auch mal zum laufen gebracht nur scheint es des öfteren nicht zu gehen.. sourcecode technisch versteh ich das nur verstehe nicht warum diese fehlermeldungen erscheinen...