callback i forlængelse af artiklen om RMI avanceret.
Hejsa igen.Hvis det ikke gør noget, så har jeg et lille spørgsmål mere ang callback, i forlængelse af hjælpen til RMI avanceret.
i min MyServerImpl har jeg følgende kode
public void join(MyClient c, String alias) throws RemoteException
{
cs.join(c, alias);
MyClient cli = (MyClient) c;
cli.spillerListe(cs.returnSpillere());
}
i ControllerServer ( som er den cs.join kalder)
public void join(MyClient c, String alias)
{
spiller = new Spiller(c, alias);
list.add(spiller);
System.out.println(c + "," + alias);
}
i min MyClientImpl ser der sådan her ud
public void spillerListe (ArrayList a)
{
cc.returnSpillere(a);
}
og til sidst i min ControllerClient (den som cc.returnSpillere kalder)
public void returnSpillere(ArrayList a)
{
System.out.println("Spillerliste " + a);
}
Men når jeg kører det, så får jeg denne stribe fejl.
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.MarshalException: error marshalling arguments; nested exception
is:
java.io.NotSerializableException: server.Spiller
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at server.MyServerImpl_Stub.join(Unknown Source)
at client.ClientMain.<init>(ClientMain.java:46)
at client.ClientTest.main(ClientTest.java:17)
Caused by: java.rmi.MarshalException: error marshalling arguments; nested except
ion is:
java.io.NotSerializableException: server.Spiller
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
at client.MyClientImpl_Stub.spillerListe(Unknown Source)
at server.MyServerImpl.join(MyServerImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.io.NotSerializableException: server.Spiller
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at java.util.ArrayList.writeObject(ArrayList.java:529)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:80
9)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:12
96)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.jav
a:1247)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:265)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:124)
... 13 more
Hvad er problemet til dette.
