我正在开发一个RMI项目,它有两个独立的Client和Server项目.我用了启动rmiregistry.当我尝试运行我的服务器应用程序时,我得到一个例外.
public class Runner extends UnicastRemoteObject {
public Runner() throws RemoteException {
try {
ServerOperations so = new ServerSide();
Naming.rebind("rmi://localhost:2000/MiveCoffeeService", so);
System.out.println("Server is online.");
} catch (RemoteException | MalformedURLException | FileNotFoundException ex) {
Logger.getLogger(Runner.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main(String[] args) throws RemoteException {
new Runner();
}
}
Run Code Online (Sandbox Code Playgroud)
例外情况是:
Sep 11, 2015 9:05:51 PM ir.nscogroup.coffeemive.Runner <init>
SEVERE: null
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: dataaccess.ServerSide
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:177)
at ir.nscogroup.coffeemive.Runner.<init>(Runner.java:29)
at ir.nscogroup.coffeemive.Runner.main(Runner.java:38)
Caused by: …Run Code Online (Sandbox Code Playgroud) 在我使用withSnackbar. 但现在它失败了,我真的不知道如何解决这个问题。所以任何帮助将不胜感激。谢谢。
这是我在组件中的导出:
export default withSnackbar(StoryApp)Run Code Online (Sandbox Code Playgroud)
这是我的测试:
let story = {
Title: "title 1",
body: "body 1",
UserEntityKey: "userEntityKey",
Key: "storyKey"
}
afterEach(() => {
// cleaning up the mess left behind the previous test
MockAxios.reset();
});
test('Story deletes based on mocked backend response', async () => {
window.confirm = jest.fn()
window.confirm.mockReturnValue(1);
let idToken = "asdf"
MockAxios.delete.mockImplementationOnce(() =>
Promise.resolve(story.Key)
)
const storyApp = shallow(<StoryApp />);
storyApp.setState((prev) => {
prev.data.push(story)
return prev
})
// Test without idToken
await storyApp.instance().deleteStory(story) …Run Code Online (Sandbox Code Playgroud)