how access control exception is removed

Pls suggest me how to overcome with this problem .

I have only this simple code=============>>

public MyRemoteServer() {

try {

MyRemote c = new MyRemoteImpl();

if (System.getSecurityManager() == null) {

System.setSecurityManager(new RMISecurityManager());

}

Registry r=LocateRegistry.createRegistry(1099);

Naming.rebind("rmi://192.168.0.60:1099/CalculatorService", c);

System.out.println("Server is now running ,waiting for client's stimlus");

} catch (Exception e) {

System.out.println("Trouble: " + e);

e.printStackTrace();

}

}

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

and i got the following exception :============>>

java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.60:1099 connect,resolve)

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)

at java.security.AccessController.checkPermission(AccessController.java:401)

at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)Trouble: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.60:1099 connect,resolve)

at java.lang.SecurityManager.checkConnect(SecurityManager.java:1026)

at java.net.Socket.connect(Socket.java:446)

at java.net.Socket.connect(Socket.java:402)

at java.net.Socket.<init>(Socket.java:309)

at java.net.Socket.<init>(Socket.java:124)

at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)

at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)

at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)

at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)

at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)

at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)

at java.rmi.Naming.rebind(Naming.java:160)

at com.myrmi.server.MyRemoteServer.<init>(MyRemoteServer.java:22)

at com.myrmi.server.MyRemoteServer.main(MyRemoteServer.java:32)

what things sud i do.

how to set code base ?

pls help

[2352 byte] By [Manish_K_Agarwal] at [2007-9-30 20:21:02]
# 1
You must create and specify a policy file that allows your application to stablish socket connection Give a look at this link http://java.sun.com/docs/books/tutorial/rmi/running.html
tcristino at 2007-7-7 1:05:53 > top of Java-index,Core,Core APIs...
# 2
HiThis is the server so you don't need a security manager. Take away that one and your error is gone.The client on the other hand needs a policy file!/Fredrik
lk95jofr at 2007-7-7 1:05:53 > top of Java-index,Core,Core APIs...
# 3

Thanx Fedrik

I got it. Thanx a lot for ur co -operation.

The summary is that we dont need to specify any security manager

or code base at server side.

at client side we'll provide the security manager and codepase property

like

System.setProperty("java.security.policy","C:/myrmi.policy");

System.setProperty("java.rmi.server.codebase", "http://192.168.0.11:8080/rmiclientclasses/");

but the restriction( or drawback) is that we can only specify the url of http server.

the policy file is like this >

grant

{

permission java.net.SocketPermission "*:1024-65535","connect,accept,listen,resolve";

permission java.security.AllPermission;

};

once again thanx Fedrik

Regards

Manish Agarwal

manish_09aug@yahoo.com

manish.agarwal@daffodilwoods.com

Manish_K_Agarwal at 2007-7-7 1:05:53 > top of Java-index,Core,Core APIs...
# 4

Hi

You should not need a codebase on the client.

The client gets the classes dynamiclly from the server because the server has specified the codebase.

Also your policy file shall not have AllPermission unless you kow it if safe!

I think this would be enough:

grant

{ permission java.net.SocketPermission

"*:1024-65535", "connect,accept";

permission java.net.SocketPermission

"*:80", "connect";

};

/Fredrik

lk95jofr at 2007-7-7 1:05:53 > top of Java-index,Core,Core APIs...