我创建了这个代码来通知我的程序的观察者。但是当我调用 notfyObservers() 方法时,它给了我错误。这是 Java RMI 程序。
IllegalArgumentException:Java 中的参数类型不匹配
notifyObserver() 方法:
@Override
public void notifyObservers(JPanel ob) throws RemoteException {
Object[] arrLocal;
synchronized (this) {
if (!changed) {
return;
}
arrLocal = listObs.toArray();
clearChanged();
}
for (int i = arrLocal.length - 1; i >= 0; i--) {
((RemoteObserver) arrLocal[i]).modify(this, ob);
}
}
称为..
questionController.notifyObservers(null);
我在 a 中调用此方法JPanel
,而我的错误是当我通过 jpanel 时..
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: javax.swing.GroupLayout
如果我通过null,我得到了。
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
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:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
提前致谢!