• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

exception in client side

 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
}
}
 
Good night. Drive safely. Here's a tiny ad for the road:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic