0

Just when I thought I know how RMI works, it comes back and tell me I do not. The following situation:

I have given:

The interface offers cleary 3 getter methods to gain informations about the object. I simply want to lookup the object call the three methods and print out theirs values:

However the following implementation ( http://pastebin.com/d4JS0Wai ) does not do the trick resulting in the following exception:

Exception in thread "main" java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: Article at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at rmi.ArticleDisplayer.main(ArticleDisplayer.java:21)

Caused by: java.lang.ClassNotFoundException: Article at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) ...

Also I don't know why I should need a SecurityManager anyway, as my machine is not executing the code. The code is executed on the machine running the rmiregistry. Anyway this is my policy file: http://pastebin.com/chGEqceA

4

2 回答 2

0

出现此问题是因为您应该具有可供客户端和源应用程序访问的相同类。 Article

您可以Jar使用 2 个模块(客户端和服务器)使用的公共类并使用它(我通常将这些类型的包命名为“commons”)。

于 2011-02-21T17:05:26.820 回答
0

好的,问题的答案:

实现以及接口都在默认包中。我在自己的包中编写了程序:rmi

还有我在rmi包中下载的接口。事实上 rmi.Article != 文章。

于 2011-02-21T17:06:33.930 回答