JAVA RMI无法远程调用

我把一个RMI的CLIENT调用类放在SERVER的工程里执行可以正常调用,但是如果把它拷到一个新项目中却无法执行,代码如下:Javacode//服务器代码package... 我把一个RMI的CLIENT调用类放在SERVER的工程里执行可以正常调用,但是如果把它拷到一个新项目中却无法执行,代码如下:
Java code
//服务器代码
package server;

import java.rmi.Remote;

import java.rmi.RemoteException;

public interface SayHello extends Remote {// 需要从Remote继承

public String sayHello(String info) throws RemoteException; // 需要抛出remote异常n;

}

package server;

import java.rmi.RemoteException;

import java.rmi.server.UnicastRemoteObject;

public class SayHelloImpl extends UnicastRemoteObject implements SayHello {

protected SayHelloImpl() throws RemoteException {

super();

// TODO Auto-generated constructor stub

}

public String sayHello(String info) throws RemoteException {

return "hello=" + info;

}

}

package server;

import java.rmi.*;

import java.net.*;

public class SayRmiServer {

public SayRmiServer() {

}

public static void main(String args[]) throws RemoteException,
MalformedURLException {

SayHelloImpl add = new SayHelloImpl();

Naming.rebind("RMI_Test_2", add);

}

}

//客户端代码,接口文件就不重复拷了
package client;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import server.SayHello;

public class SayRmiClient {

public SayRmiClient() {

}

public static void main(String args[]) throws RemoteException,

MalformedURLException, NotBoundException {

String url = "rmi://110.64.89.140" +
"/RMI_Test_2";
SayHello add = (SayHello) Naming.lookup(url);

String result = add.sayHello("hubin");

System.out.println(result);

}
}

执行后抛出如下异常:
Exception in thread "main" java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: server.SayHello (no security manager: RMI class loader disabled)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at client.SayRmiClient.main(SayRmiClient.java:22)
Caused by: java.lang.ClassNotFoundException: server.SayHello (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 3 more
展开
 我来答
fangliangmeng
2011-03-16 · 超过28用户采纳过TA的回答
知道答主
回答量:67
采纳率:0%
帮助的人:72.7万
展开全部
java.lang.ClassNotFoundException: server.SayHello (no security manager: RMI class loader disabled)

缺少jar包,异常显示是缺少server.SayHello这个方法,确认新项目中是不是少了jar包。
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式