求救,RMI中绑定出错,急急急,,巨分狂送,不够再加!!!!!!!!!!
凌波微搏 2002-09-26 09:29:48 如能留下Email,或者QQ,就更好。
在运行一个Rmi服务端程序的时候提示绑定出错,下面是打印出来的出错信息,这个程序是一个例程。
java.security.AccessControlException: access denied (java.net.SocketPermission 1
27.0.0.1:10009 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:419)
at java.net.Socket.connect(Socket.java:375)
at java.net.Socket.<init>(Socket.java:290)
at java.net.Socket.<init>(Socket.java:118)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:122)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185
)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:159)
at LocalRemoteServer.<init>(LocalRemoteServer.java:81)
at LocalRemoteServer.main(LocalRemoteServer.java:38)
主程序:
/**
* Class: LocalRemoteServer
*
*/
import java.net.*;
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.LocateRegistry;
public class LocalRemoteServer
{
private static final int PORT = 10009;
//
// -> Change the name to your own computer name
//
private static final String HOST_NAME = "LocalHost";
// Instance of ourselves
private static LocalRemoteServer lrs;
public static void main
(
String[] args
)
{
// We need to set the security manager to the RMISecurityManager
System.setSecurityManager( new RMISecurityManager() );
try
{
lrs = new LocalRemoteServer();
}
catch ( java.rmi.UnknownHostException uhe )
{
System.out.println( "The host computer name you have specified, " + HOST_NAME + " does not match your real computer name." );
}
catch ( RemoteException re )
{
System.out.println( "Error starting service" );
System.out.println( "" + re );
}
catch ( MalformedURLException mURLe )
{
System.out.println( "Internal error" + mURLe );
}
catch ( NotBoundException nbe )
{
System.out.println( "Not Bound" );
System.out.println( "" + nbe );
}
} // main
// Constructor
public LocalRemoteServer()
throws RemoteException,
MalformedURLException,
NotBoundException
{
LocateRegistry.createRegistry( PORT );
System.out.println( "Registry created on host computer " + HOST_NAME + " on port " + Integer.toString( PORT) );
RemoteModelMgrImpl rmmImpl = new RemoteModelMgrImpl();
System.out.println( "RemoteModelImpl object created" );
String urlString = "//" + HOST_NAME + ":" + Integer.toString( PORT ) + "/" + "RemoteModelManager";
try
{
Naming.rebind( urlString, rmmImpl );
}
catch(Exception e)
{
System.out.println("bind error..............");
e.printStackTrace();
System.exit(0);
}
System.out.println( "Bindings Finished, waiting for client requests." );
}
} // class LocalRemoteServer