Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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);
}
}
}
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic