Java exception java security access denied



java.security.AccessControlException: access denied

My RMI application is to let the client send an ArrayList of bean class (a set of getter/setter methods) to a remote server. Error occured as below:

java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.186: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)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1026)

1. AT SERVER SIDE (using j2sdk1.4.2_10)
a) RemoteDeliverSMSInterface.java
b) RemoteDeliverSMSImp.java

public static void main(String args[]) <
if (System.getSecurityManager() == null) <
System.setSecurityManager(new RMISecurityManager());
>
try <
RemoteDeliverSMSInterface rdsms = new RemoteDeliverSMSImp();
Naming.rebind(«SMSsend»,rdsms);
>catch(Exception e) <
e.printStackTrace();
>
>

java -Djava.security.policy=c:\java.policy RemoteDeliverSMSImp

**java.policy
grant <
// Allow everything for now
permission java.security.AllPermission;
>;

2. AT CLIENT SIDE (using j2sdk1.4.2_08)

if (System.getSecurityManager() == null) <
System.setSecurityManager(new RMISecurityManager());
>

try <
RemoteDeliverSMSInterface service = (RemoteDeliverSMSInterface) Naming.lookup(«rmi://192.168.0.186/SMSsend»);
service.remoteDeliverSMS(smsBeanList);
>catch(Exception e) <
e.printStackTrace();
>

Even though i already allow all access in policy, but the access denied still persisted? Any help would be appreciated.

Comments

i want to run a server with RMI but not connect or not open the port at the server.

help about this error of RMI at SERVER
I have JDK 1.5.0_07
Netbeans 5

HOW TO CREATE A RMI PROYECT that not do nothing at comand line
and only work at netbeans IDE
ERROR ERROR ERROR ERROR ERROR

You should put this command in beginning of your server code:

Then, it will be work fine! Hope this can help you

Thanks very much, sosseres. I’ve looked through just about every thread on this forum regarding RMI, and your suggestion was the one that finally worked.

hi. in my case it does not work. application code:
try
<

if (System.getSecurityManager()==null) <
System.setSecurityManager(new RMISecurityManager());
>
System.setProperty(«java.security.policy», «policy»);
LocateRegistry.createRegistry(Registry.REGISTRY_PORT);

//create a local instance of the object

READ  Padovan прошивка кто это

//UserCreator uc = new UserCreator();
testlogin tl = new testlogin();

Источник

Smartadm.ru