我编了一个入门的RMI程序,也成功调用rmic生成了两个框架类,安全文件也编写的没问题,但运行服务端时,老是报这样一个错:
HelloImpl.main: an exception occured:
java.rmi.ServerException: Server RemoteException; nested exception is:
        java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
        java.lang.ClassNotFoundException: hello.HelloImpl_Stub
        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:350)
        at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
        at java.rmi.Naming.rebind(Naming.java:160)
        at hello.HelloImpl.main(HelloImpl.java:27)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
ception is:
        java.lang.ClassNotFoundException: hello.HelloImpl_Stub
Caused by: java.lang.ClassNotFoundException: hello.HelloImpl_Stub问题应该是找不到框架类hello.HelloImpl_Stub,但我已经成功调用过rmic了,而且也已经把它的相关位置设进了-classpath中了。我看以前的帖子说“rmiregistry必须要能够找到stub,skeleton”
我不明白如何才能让rmiregistry找到stub,skeleton,
有高人告诉我应该这样调用rmiregistry -Jjava.rmi.codebase=某个url
我分别这样试了试(我的桩类在g:/hello/hello里面):
rmiregistry -Jjava.rmi.codebase=g:/hello
rmiregistry -Jjava.rmi.codebase=g:/hello/
rmiregistry -Jjava.rmi.codebase=g:/hello/hello/
rmiregistry -Jjava.rmi.codebase=file://g:/hello
rmiregistry -Jjava.rmi.codebase=file://g:/hello/hello
rmiregistry -Jjava.rmi.codebase=file://g:/hello/
rmiregistry -Jjava.rmi.codebase=file://g:/hello/hello/
报告如下错误:
Error loading class java/rmi/codebase=g:/hello/hello: Bad major version number下面该怎么办啊,请高人指点指点,万分感激。(我在网上查了一下,有这个问题的很多,有的解决了,但都没有具体帖出是如何解决的)

解决方案 »

  1.   

    ClassNotFoundException只能说明是你的ClassPath设置有问题,不关rmi的什么事情你的程序应该是hello.HelloImpl.class吧,
    把hello.HelloImpl_Stub和hello.HelloImpl_skeleton放到你的相应的class目录下就行了,
    还有,你的java -version是什么?
      

  2.   

    可以不管三七二十一,把hello.HelloImpl_Stub和hello.HelloImpl_skeleton同时放在客户端和服务端的
    classpath中试试
      

  3.   

    路径问题,在 与“hello文件夹同层”的地方 执行javac
      

  4.   

    试一下rmiregistry -J-Djava.rmi.codebase=file://g:/hello/