title: java rmi - access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
body: <p>I've seared the web for an answer but nothing helped me.
  I'm trying to run an RMI server I created.
  in the server main I have this part:</p>
  
  <pre><code>System.setSecurityManager(new RMISecurityManager());
  ...
  ...
  ...
  Naming.rebind("//localhost/ForumSite", obj);
  </code></pre>
  
  <p>my policy file :server,policy(the ... is leading to the folder)-</p>
  
  <pre><code>grant codeBase "file:C:/.../workspace//ForunServer/bin/" {
      permission java.security.AllPermission;
      permission java.net.SocketPermission "localhost:1099-", "listen, connect, resolve";
  
  };
  
  grant {
   permission java.lang.RuntimePermission "setSecurityManager";
    permission java.lang.RuntimePermission "createSecurityManager";
    permission java.lang.RuntimePermission "usePolicy";
    };
  </code></pre>
  
  <p>I'm trying to run a Windows O.S, I wrote in another consloe: javaw rmiregistry
  and in another one(from the bin folder):</p>
  
  <pre><code>java -Djava.security.manager -Djava.security.policy=server.policy ServerSideImp
  </code></pre>
  
  <p>I've keep on getting the error:</p>
  
  <blockquote>
    <p>access denied ("java.net.SocketPermission" "127.0.0.1:1099"
    "connect,resolve")</p>
  </blockquote>
  
  <p>I made sure the policy file is in the same location,</p>
  
  <p>here is the run results when I add -Djava.security.debug=access,failure to the run-</p>
  
  <blockquote>
    <p>access: access allowed ("java.io.FilePermission"
    "C:\Users...\ForumServer\bin" "read") access: access allowed
    ("java.lang.RuntimePermission" "setSecurityManager") access: access
    allowed ("java.security.SecurityPermission"
    "getProperty.security.provider.1") access: access allowed
    ("java.security.SecurityPermission" "getProperty.security.provider.2")
    access: access allowed ("java.security.SecurityPermission"
    "getProperty.security.provider.3") access: access allowed
    ("java.security.SecurityPermission" "getProperty.security.provider.4")
    access: access allowed ("java.security.SecurityPermission"
    "getProperty.security.provider.5") access: access allowed
    ("java.security.SecurityPermission" "getProperty.security.provider.6")
    access: access allowed ("java.security.SecurityPermission"
    "getProperty.security.provider.7") access: access allowed
    ("java.security.SecurityPermission" "getProperty.security.provider.8")
    access: access allowed ("java.security.SecurityPermission"
    "getProperty.security.provider.9") access: access allowed
    ("java.security.SecurityPermission"
    "getProperty.security.provider.10") access: access allowed
    ("java.security.SecurityPermission"
    "getProperty.security.provider.11") access: access allowed
    ("java.lang.RuntimePermission"
    "accessClassInPackage.sun.security.provider") access: access allowed
    ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access:
    access allowed ("java.util.PropertyPermission" "java.security.egd"
    "read") access: access allowed ("java.security.SecurityPermission"
    "getProperty.securerandom.source") access: access allowed
    ("java.security.SecurityPermission" "putProviderProperty.SUN") access:
    access allowed ("java.util.PropertyPermission" "*" "read,write")
    access: access allowed ("java.util.PropertyPermission" "os.arch"
    "read") access: access allowed ("java.lang.RuntimePermission"
    "loadLibrary.net") access: access allowed ("java.io.FilePermission"
    "C:\Program Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access
    allowed ("java.util.PropertyPermission" "java.net.preferIPv4Stack"
    "read") access: access allowed ("java.util.PropertyPermission"
    "java.net.preferIPv6Addresses" "read") access: access allowed
    ("java.lang.RuntimePermission" "loadLibrary.net") access: access
    allowed ("java.io.FilePermission" "C:\Program
    Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access allowed
    ("java.util.PropertyPermission" "impl.prefix" "read") access: access
    allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
    access: access allowed ("java.util.PropertyPermission"
    "sun.net.spi.nameservice.provider.1" "read") access: access allowed
    ("java.net.NetPermission" "getNetworkInformation") access: access
    allowed ("java.net.NetPermission" "getNetworkInformation") access:
    access allowed ("java.net.NetPermission" "getNetworkInformation")
    access: access allowed ("java.net.NetPermission"
    "getNetworkInformation") access: access allowed
    ("java.net.NetPermission" "getNetworkInformation") access: access
    allowed ("java.net.NetPermission" "getNetworkInformation") access:
    access allowed ("java.net.NetPermission" "getNetworkInformation")
    access: access allowed ("java.net.NetPermission"
    "getNetworkInformation") access: access allowed
    ("java.net.NetPermission" "getNetworkInformation") access: access
    allowed ("java.net.NetPermission" "getNetworkInformation") access:
    access allowed ("java.net.NetPermission" "getNetworkInformation")
    access: access allowed ("java.lang.RuntimePermission"
    "fileSystemProvider") access: access allowed
    ("java.util.PropertyPermission" "user.dir" "read") access: access
    allowed ("java.util.PropertyPermission" "os.version" "read") access:
    access allowed ("java.util.PropertyPermission" "sun.jnu.encoding"
    "read") access: access allowed ("java.util.PropertyPermission"
    "java.nio.file.spi.DefaultFileSystemProvider" "read") access: access
    allowed ("java.io.FilePermission" "C:\Users\URI\AppData\Local\Temp"
    "read") access: access allowed ("java.io.FilePermission"
    "C:\Users\URI\AppData\Local\Temp" "read") access: access allowed
    ("java.io.FilePermission" "C:\Users\URI\AppData\Local\Temp" "read")
    access: access allowed ("java.lang.RuntimePermission"
    "loadLibrary.net") access: access allowed ("java.io.FilePermission"
    "C:\Program Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access
    allowed ("java.lang.RuntimePermission" "loadLibrary.nio") access:
    access allowed ("java.io.FilePermission" "C:\Program
    Files\Java\jre1.8.0_45\bin\nio.dll" "read") access: access allowed
    ("java.util.PropertyPermission" "sun.nio.fs.ensureAccurateMetadata"
    "read") access: access allowed ("java.util.PropertyPermission"
    "java.rmi.server.randomIDs" "read") access: access allowed
    ("java.util.PropertyPermission" "java.rmi.server.hostname" "read")
    access: access allowed ("java.security.SecurityPermission"
    "getProperty.networkaddress.cache.ttl") access: access allowed
    ("java.util.PropertyPermission" "sun.net.inetaddr.ttl" "read") access:
    access allowed ("java.security.SecurityPermission"
    "getProperty.networkaddress.cache.negative.ttl") access: access denied
    ("java.net.SocketPermission" "URI-PC" "resolve") java.lang.Exception:
    Stack trace
            at java.lang.Thread.dumpStack(Unknown Source)
            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.checkConnect(Unknown Source)
            at java.net.InetAddress.getLocalHost(Unknown Source)
            at sun.rmi.transport.tcp.TCPEndpoint.(Unknown Source)
            at sun.rmi.transport.LiveRef.(Unknown Source)
            at sun.rmi.transport.LiveRef.(Unknown Source)
            at sun.rmi.server.UnicastServerRef.(Unknown Source)
            at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source)
            at java.rmi.server.UnicastRemoteObject.(Unknown Source)
            at java.rmi.server.UnicastRemoteObject.(Unknown Source)
            at ServerSideImp.(ServerSideImp.java:18)
            at ServerSideImp.main(ServerSideImp.java:62) access: access allowed ("java.security.SecurityPermission" "getPolicy") access:
    access allowed ("java.io.FilePermission" "C:\Users...\ForumServer\bin"
    "read") access: domain that failed ProtectionDomain 
    (file:/C:/Users/.../ForumServer/bin/ ) 
    sun.misc.Launcher$AppClassLoader@73d16e93   
    java.security.Permissions@6f94fa3e (  ("java.lang.RuntimePermission"
    "setSecurityManager")  ("java.lang.RuntimePermission"
    "createSecurityManager")  ("java.lang.RuntimePermission" "exitVM") 
    ("java.lang.RuntimePermission" "usePolicy") 
    ("java.lang.RuntimePermission" "stopThread") 
    ("java.util.PropertyPermission" "java.specification.version" "read") 
    ("java.util.PropertyPermission" "java.version" "read") 
    ("java.util.PropertyPermission" "os.arch" "read") 
    ("java.util.PropertyPermission" "java.specification.vendor" "read") 
    ("java.util.PropertyPermission" "java.vm.specification.name" "read") 
    ("java.util.PropertyPermission" "java.vm.vendor" "read") 
    ("java.util.PropertyPermission" "path.separator" "read") 
    ("java.util.PropertyPermission" "os.version" "read") 
    ("java.util.PropertyPermission" "file.separator" "read") 
    ("java.util.PropertyPermission" "line.separator" "read") 
    ("java.util.PropertyPermission" "java.vm.specification.vendor" "read")
    ("java.util.PropertyPermission" "java.specification.name" "read") 
    ("java.util.PropertyPermission" "java.vendor.url" "read") 
    ("java.util.PropertyPermission" "java.vendor" "read") 
    ("java.util.PropertyPermission" "java.vm.version" "read") 
    ("java.util.PropertyPermission" "java.vm.name" "read") 
    ("java.util.PropertyPermission" "java.vm.specification.version"
    "read")  ("java.util.PropertyPermission" "os.name" "read") 
    ("java.util.PropertyPermission" "java.class.version" "read") 
    ("java.net.SocketPermission" "localhost:0" "listen,resolve") 
    ("java.io.FilePermission" "\C:\Users...\ForumServer\bin-" "read") )</p>
    
    <p>access: access allowed ("java.util.PropertyPermission"
    "java.rmi.server.useLocalHostName" "read") access: access allowed
    ("java.util.PropertyPermission" "sun.rmi.transport.logLevel" "read")
    access: access allowed ("java.util.logging.LoggingPermission"
    "control") access: access allowed
    ("java.util.logging.LoggingPermission" "control") access: access
    allowed ("java.util.PropertyPermission"
    "sun.rmi.transport.tcp.logLevel" "read") access: access allowed
    ("java.util.logging.LoggingPermission" "control") access: access
    allowed ("java.util.logging.LoggingPermission" "control") access:
    access allowed ("java.util.PropertyPermission"
    "sun.rmi.transport.tcp.maxConnectionThreads" "read") access: access
    allowed ("java.util.PropertyPermission"
    "sun.rmi.transport.tcp.threadKeepAliveTime" "read") access: access
    allowed ("java.util.PropertyPermission"
    "sun.rmi.transport.proxy.logLevel" "read") access: access allowed
    ("java.util.logging.LoggingPermission" "control") access: access
    allowed ("java.util.logging.LoggingPermission" "control") access:
    access allowed ("java.util.PropertyPermission"
    "sun.rmi.transport.proxy.connectTimeout" "read") access: access
    allowed ("java.util.PropertyPermission"
    "sun.rmi.transport.proxy.eagerHttpFallback" "read") access: access
    allowed ("java.util.PropertyPermission" "http.proxyHost" "read")
    access: access allowed ("java.util.PropertyPermission" "proxyHost"
    "read") access: access allowed ("java.util.PropertyPermission"
    "java.rmi.server.disableHttp" "read") access: access allowed
    ("java.util.PropertyPermission" "sun.rmi.transport.tcp.readTimeout"
    "read") access: access allowed ("java.util.PropertyPermission"
    "java.rmi.server.hostname" "read") access: access allowed
    ("java.util.PropertyPermission"
    "sun.misc.ProxyGenerator.saveGeneratedFiles" "read") access: access
    allowed ("java.util.PropertyPermission"
    "sun.rmi.dgc.server.gcInterval" "read") access: access allowed
    ("java.lang.RuntimePermission" "loadLibrary.net") access: access
    allowed ("java.io.FilePermission" "C:\Program
    Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access allowed
    ("java.util.PropertyPermission" "<em>" "read,write") access: access
    allowed ("java.util.PropertyPermission" "</em>" "read,write") access:
    access allowed ("java.util.PropertyPermission"
    "sun.net.useExclusiveBind" "read") access: access allowed
    ("java.net.SocketPermission" "localhost:0" "listen,resolve") access:
    access allowed ("java.lang.RuntimePermission" "modifyThreadGroup")
    access: access allowed ("java.lang.RuntimePermission"
    "modifyThreadGroup") access: access allowed
    ("java.lang.RuntimePermission" "getClassLoader") access: access
    allowed ("java.lang.RuntimePermission" "modifyThreadGroup") access:
    access allowed ("java.lang.RuntimePermission" "modifyThread") access:
    access allowed ("java.lang.RuntimePermission" "setContextClassLoader")
    access: access allowed ("java.lang.RuntimePermission" "modifyThread")
    access: access allowed ("java.util.PropertyPermission"
    "sun.rmi.dgc.logLevel" "read") access: access allowed
    ("java.util.logging.LoggingPermission" "control") access: access
    allowed ("java.util.logging.LoggingPermission" "control") access:
    access allowed ("java.util.PropertyPermission"
    "java.rmi.dgc.leaseValue" "read") access: access allowed
    ("java.util.PropertyPermission" "sun.rmi.dgc.checkInterval" "read")
    access: access allowed ("java.util.logging.LoggingPermission"
    "control") access: access allowed
    ("java.util.logging.LoggingPermission" "control") access: access
    allowed ("java.util.PropertyPermission"
    "sun.rmi.runtime.schedulerThreads" "read") access: access allowed
    ("java.lang.RuntimePermission"
    "sun.rmi.runtime.RuntimeUtil.getInstance") access: access allowed
    ("java.lang.RuntimePermission" "setContextClassLoader") access: access
    allowed ("java.util.PropertyPermission" "java.rmi.server.hostname"
    "read") access: access allowed ("java.lang.reflect.ReflectPermission"
    "suppressAccessChecks") access: access allowed
    ("java.lang.RuntimePermission" "setContextClassLoader") access: access
    allowed ("java.lang.RuntimePermission" "getClassLoader") access:
    access allowed ("java.lang.RuntimePermission" "modifyThreadGroup")
    access: access allowed ("java.lang.RuntimePermission" "modifyThread")
    access: access allowed ("java.lang.RuntimePermission"
    "setContextClassLoader") access: access allowed
    ("java.lang.RuntimePermission" "modifyThread") access: access allowed
    ("java.lang.RuntimePermission" "modifyThreadGroup") access: access
    allowed ("java.lang.RuntimePermission" "modifyThreadGroup") access:
    access allowed ("java.lang.RuntimePermission" "modifyThread") access:
    access allowed ("java.lang.RuntimePermission" "modifyThread") access:
    access allowed ("java.lang.RuntimePermission" "modifyThread") access:
    access allowed ("java.lang.reflect.ReflectPermission"
    "suppressAccessChecks") access: access allowed
    ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access:
    access allowed ("java.util.PropertyPermission"
    "java.rmi.server.hostname" "read") access: access allowed
    ("java.util.PropertyPermission" "sun.rmi.transport.connectionTimeout"
    "read") access: access allowed ("java.util.PropertyPermission"
    "sun.rmi.transport.tcp.handshakeTimeout" "read") access: access
    allowed ("java.util.PropertyPermission"
    "sun.rmi.transport.tcp.responseTimeout" "read") access: access allowed
    ("java.lang.RuntimePermission"
    "sun.rmi.runtime.RuntimeUtil.getInstance") access: access allowed
    ("java.net.SocketPermission" "localhost" "resolve") access: access
    allowed ("java.util.PropertyPermission"
    "jdk.net.ephemeralPortRange.low" "read") access: access allowed
    ("java.lang.RuntimePermission" "loadLibrary.net") access: access
    allowed ("java.io.FilePermission" "C:\Program
    Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access allowed
    ("java.util.PropertyPermission" "jdk.net.ephemeralPortRange.high"
    "read") access: access denied ("java.net.SocketPermission"
    "127.0.0.1:1099" "connect,resolve") java.lang.Exception: Stack trace
            at java.lang.Thread.dumpStack(Unknown Source)
            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.checkConnect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at java.net.Socket.(Unknown Source)
            at java.net.Socket.(Unknown Source)
            at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown
    Source)
            at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown
    Source)
            at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
            at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
            at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
            at sun.rmi.server.UnicastRef.newCall(Unknown Source)
            at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
            at java.rmi.Naming.rebind(Unknown Source)
            at ServerSideImp.main(ServerSideImp.java:63) access: access allowed ("java.security.SecurityPermission" "getPolicy") access:
    access allowed ("java.io.FilePermission" "C:\Users...\ForumServer\bin"
    "read") access: domain that failed ProtectionDomain 
    (file:/C:/Users/.../ForumServer/bin/ ) 
    sun.misc.Launcher$AppClassLoader@73d16e93   
    java.security.Permissions@2c7b84de (  ("java.lang.RuntimePermission"
    "setSecurityManager")  ("java.lang.RuntimePermission"
    "createSecurityManager")  ("java.lang.RuntimePermission" "exitVM") 
    ("java.lang.RuntimePermission" "usePolicy") 
    ("java.lang.RuntimePermission" "stopThread") 
    ("java.util.PropertyPermission" "java.specification.version" "read") 
    ("java.util.PropertyPermission" "java.version" "read") 
    ("java.util.PropertyPermission" "os.arch" "read") 
    ("java.util.PropertyPermission" "java.specification.vendor" "read") 
    ("java.util.PropertyPermission" "java.vm.specification.name" "read") 
    ("java.util.PropertyPermission" "java.vm.vendor" "read") 
    ("java.util.PropertyPermission" "path.separator" "read") 
    ("java.util.PropertyPermission" "os.version" "read") 
    ("java.util.PropertyPermission" "file.separator" "read") 
    ("java.util.PropertyPermission" "line.separator" "read") 
    ("java.util.PropertyPermission" "java.vm.specification.vendor" "read")
    ("java.util.PropertyPermission" "java.specification.name" "read") 
    ("java.util.PropertyPermission" "java.vendor.url" "read") 
    ("java.util.PropertyPermission" "java.vendor" "read") 
    ("java.util.PropertyPermission" "java.vm.version" "read") 
    ("java.util.PropertyPermission" "java.vm.name" "read") 
    ("java.util.PropertyPermission" "java.vm.specification.version"
    "read")  ("java.util.PropertyPermission" "os.name" "read") 
    ("java.util.PropertyPermission" "java.class.version" "read") 
    ("java.net.SocketPermission" "localhost:0" "listen,resolve") 
    ("java.io.FilePermission" "\C:\Users...\ForumServer\bin-" "read") )</p>
    
    <p>access: access allowed ("java.lang.RuntimePermission" "exitVM.1")</p>
  </blockquote>
  
  <p>but I don't really understand whats going here,
  any help would be grate.</p>