• 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

Help needed in RMI

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friends,
I have written a RMI program where the client
just queries the server and gets a string as reply.
The program compiles fine and all the settings are
proper. The rmic has generated the stubs and skeletons.
But when the server is run, it prints an AccessControl
Exception and then waits. I donot know why this is
happening. I am connected to the internet when I
run the program. Can any one help me in this regard ?
Thanks
Sandeep
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The access control access generally happens when there is security permission not granted for certain permission type. You need to provide more information about the error you received to debug the problem.
 
sandeep iyer
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Asad Ali,
My program is given below. It compiles fine and all stubs and skeletons are generated. I saw in an earlier posting that u must change the security policy. I want to know some details about this. May be specifying "localhost" has a problem.
/* ---------- This is the interface -------------- */
import java.rmi.*;
public interface RMIServer extends Remote{
public String getName() throws RemoteException;
}
/* ------------------------------------------- */
/* ----------- This is interface implementation -------------*/
import java.rmi.*;
import java.rmi.server.*;
public class RMIimpl extends UnicastRemoteObject implements RMIServer{

public RMIimpl() throws RemoteException{
super();
}
public static void main(String []args){
System.setSecurityManager(new RMISecurityManager());
try{
RMIimpl rmi = new RMIimpl();
System.out.println("Server side : Done");
Naming.bind("rmi:///RMIServer", rmi);
System.out.println("Server side : Done");
}catch(Exception ex){ System.out.println(ex); }
}
public String getName() throws RemoteException{
return "My name";
}
}
/* ------------------------------------------ */
/*-------- Client ----------------*/
import java.rmi.*;
public class RMIClient{
private static String strName;
public static void main(String []args){
try{
RMIServer rmiClient = (RMIServer)Naming.lookup("rmi://localhost/RMIServer");
strName = rmiClient.getName();
System.out.println(strName);
}catch(Exception ex){System.out.println(ex);}
}
}
/* ------------------------------------- */
Thanks
Sandeep
 
asad ali
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sandeep,
I see that you are installing SecurityManager in your server. One of the errors you might be getting when you start your server is "java.net.SocketPermission". If this error is occuring, the reason is the SecurityManager is restricting your server to accept connections. To make it work, you can create your own policy file. Policy file is an ascii file containing all the permission you wish to grant to your server. Your policy file may look like this
grant {
permission java.net.SocketPermission "localhost", "connect,accept,listen,resolve";
};
If your create an ascii file called 'mypolicy' and put the above grant statement in it, then you can start your server like this
java -Djava.security.policy=mypolicy RMIImpl
The use of policy file will allow your server to accept connections.
You can learn more about policy file by going to the following URL http://java.sun.com/products/jdk/1.2/docs/guide/security/permissions.html
 
sandeep iyer
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great help Asad
Thanks a lot
I will contact back soon
Thanks for the lead
Sandeep
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic