here is my code with the main class. The error is shown in this class:
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
@SuppressWarnings("serial")
public class HelloImpl extends UnicastRemoteObject
implements Hello {
public HelloImpl() throws RemoteException {
super();
}
public String sayHello() {
return "Hello World!";
}
public static void main(String args[]) {
// Create and install a security manager
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
HelloImpl obj = new HelloImpl();
// Bind this object instance to the name "HelloServer"
System.setSecurityManager (new RMISecurityManager() {
public void checkConnect (String host, int port) {}
public void checkConnect (String host, int port, Object
context) {}
});
Naming.rebind("HelloServer", obj);
System.out.println("HelloServer bound in registry");
} catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}
This is the error that I get:
java.security.AccessControlException: access denied
(java.lang.RuntimePermission createSecurityManager)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.<init>(Unknown Source)
at HelloImpl$1.<init>(HelloImpl.java:30)
at HelloImpl.main(HelloImpl.java:30)
HelloImpl err: access denied (java.lang.RuntimePermission
createSecurityManager)
Any Help on this would be great.
Thanks a lot.
Shishir
I'm not very knowledgeable about security but I _think_ this tutorial should
help:
http://java.sun.com/docs/books/tutorial/security1.2/index.html
If it doesn't, you could try comp.lang.java.security although I suspect they
focus on more advanced security issues.
--
Rhino
One simple solution for your problem is:
omit your first call System.setSecurity(...)
--
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')