我编写了一个简单的RMI程序,报如下错误: java.security.AccessControlException: access denied (java.net.SocketPermission 1 27.0.0.1:1099 connect,resolve) at java.security.AccessControlContext.checkPermission(AccessControlConte xt.java:270) at java.security.AccessController.checkPermission(AccessController.java: 401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:542) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044) at java.net.Socket.connect(Socket.java:428) at java.net.Socket.connect(Socket.java:384) at java.net.Socket.<init>(Socket.java:291) at java.net.Socket.<init>(Socket.java:119) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect SocketFactory.java:22) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster SocketFactory.java:128) 等等......程序摘自Java编程思想,如下: import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; import java.net.*;interface PerfectTimeI extends Remote { long getPerfectTime() throws RemoteException; } ///:~ public class PerfectTime implements PerfectTimeI { // Implementation of the interface: public long getPerfectTime() throws RemoteException { return System.currentTimeMillis(); } public PerfectTime() throws RemoteException { // super(); // Called automatically } // Registration for RMI serving: public static void main(String[] args) { System.setSecurityManager(new RMISecurityManager()); try { LocateRegistry.createRegistry(2006); PerfectTime pt = new PerfectTime(); Naming.bind("////jjbobo:1099//PerfectTime", pt); //jjbobo是我的主机名 System.out.println("Ready to do time"); } catch(Exception e) { System.out.println("ERROR"); e.printStackTrace(); } } } ///:~我的机器系统是win2000
去掉后报下面的异常: 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这是怎么回事啊?
java.rmi.StubNotFoundException: Stub class not found: testrmi.RemoteObject_Stub; nested exception is: java.lang.ClassNotFoundException: testrmi.RemoteObject_Stub at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:98) at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:55) at sun.rmi.server.UnicastServerRef.setSkeleton(UnicastServerRef.java:179) at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:142) at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:129) at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:275) at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:178) at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:75) at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:61) at testrmi.RemoteObject.<init>(RemoteObject.java:14) at testrmi.RemoteObject.main(RemoteObject.java:30) Caused by: java.lang.ClassNotFoundException: testrmi.RemoteObject_Stub at java.net.URLClassLoader$1.run(URLClassLoader.java:198) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:186) at java.lang.ClassLoader.loadClass(ClassLoader.java:299) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265) at java.lang.ClassLoader.loadClass(ClassLoader.java:255) at sun.rmi.server.RemoteProxy.loadClassFromClass(RemoteProxy.java:191) at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:93) ... 10 more 我也出现这样的问题,急待高手解决啊
java.security.AccessControlException: access denied (java.net.SocketPermission 1
27.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:270)
at java.security.AccessController.checkPermission(AccessController.java:
401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044)
at java.net.Socket.connect(Socket.java:428)
at java.net.Socket.connect(Socket.java:384)
at java.net.Socket.<init>(Socket.java:291)
at java.net.Socket.<init>(Socket.java:119)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:128)
等等......程序摘自Java编程思想,如下:
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;interface PerfectTimeI extends Remote
{
long getPerfectTime() throws RemoteException;
} ///:~
public class PerfectTime implements PerfectTimeI
{
// Implementation of the interface:
public long getPerfectTime() throws RemoteException
{
return System.currentTimeMillis();
} public PerfectTime() throws RemoteException
{
// super(); // Called automatically
}
// Registration for RMI serving:
public static void main(String[] args)
{
System.setSecurityManager(new RMISecurityManager());
try
{
LocateRegistry.createRegistry(2006);
PerfectTime pt = new PerfectTime();
Naming.bind("////jjbobo:1099//PerfectTime", pt); //jjbobo是我的主机名
System.out.println("Ready to do time");
}
catch(Exception e)
{
System.out.println("ERROR");
e.printStackTrace();
}
}
} ///:~我的机器系统是win2000
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这是怎么回事啊?
是本机的IP,还是其他什么啊
我运行服务端时,是这样的:java -Djava.security.policy=my.policy hello.HelloImpl
不行啊
java.lang.ClassNotFoundException: testrmi.RemoteObject_Stub
at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:98)
at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:55)
at sun.rmi.server.UnicastServerRef.setSkeleton(UnicastServerRef.java:179)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:142)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:129)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:275)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:178)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:75)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:61)
at testrmi.RemoteObject.<init>(RemoteObject.java:14)
at testrmi.RemoteObject.main(RemoteObject.java:30)
Caused by: java.lang.ClassNotFoundException: testrmi.RemoteObject_Stub
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at sun.rmi.server.RemoteProxy.loadClassFromClass(RemoteProxy.java:191)
at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:93)
... 10 more
我也出现这样的问题,急待高手解决啊
我前天看错了,这个不是哪个安全文件,但这个URL要怎样设置.我是这样设的:
rmiregistry -Jjava.rmi.codebase=g:/hello/hello
因为我的桩类在g:/hello/hello里面。
报告如下错误:
Error loading class java/rmi/codebase=g:/hello/hello: Bad major version number我分别这样试了试:
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/
都不行,报一样的错误。
你会了把代码发给我啊,这个问题困扰我好长时间了