wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes exception in client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "exception in client side" Watch "exception in client side" New topic
Author

exception in client side

jawwad ahmed
Ranch Hand

Joined: Dec 01, 2001
Posts: 179
Well i am getting exception in HelloClient
Exception is clientjava.security.AccessControlException: access denied (java
.net.SocketPermission 127.0.0.1:1099 connect,resolve)
I don’t get the exception if I remove the following lines.
if(System.getSecurityManager()==null)
System.setSecurityManager(new RMISecurityManager());
What is the reason of it and why we set security manager .
Here is the code from wrox.
////////////////////////////////////////////
import java.rmi.*;
public interface HelloInterface extends Remote
{
public String sayHello()throws RemoteException;
}
/////////////////////////////////////////////
import java.rmi.*;
import java.rmi.server.*;
public class HelloServer extends UnicastRemoteObject implements HelloInterface
{
public HelloServer()throws RemoteException
{
super();
}
public String sayHello()throws RemoteException
{
System.out.println("going to return Hello Rmi");
return "Hello Rmi";
}
}
/////////////////////////////////////////////////
import java.rmi.*;
import java.rmi.server.*;
public class RegisterIt
{
public static void main(String args[])
{
try{
HelloServer hello=new HelloServer();
System.out.println("Object instantiated of remote");
Naming.rebind("/HelloServer",hello);
System.out.println("Object Server in the registery");
}
catch(Exception e)
{
System.out.println("Exception is in register"+e);
}
}
}
///////////////////////////////////////////
import java.rmi.*;
public class HelloClient
{
public static void main(String args[])
{
if(System.getSecurityManager()==null)
System.setSecurityManager(new RMISecurityManager());
try{
HelloInterface obj=(HelloInterface)Naming.lookup("/HelloServer");
System.out.println("object is"+obj);
String msg=obj.sayHello();
System.out.println("Message is"+msg);
}
catch(Exception e){
System.out.println("Exception is in client"+e);
}
}
}
 
 
subject: exception in client side
 
Similar Threads
Not Finding Stub
RMI Problem : java.lang.ClassCastException
RMI in netbeans on windows
Error while registring the server object to RMI registry
Problem while starting rmi server