本文參考的文章:http://blog.coffeebeans.at/?p=770html
今天運行Derby數據庫的服務器時,出現如下問題:java
access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
緣由是:shell
Java 7u51版安全管理器的默認權限有變化,以前容許綁定>1024的端口,如今下限更高。因此derby使用的1527端口被拒絕綁定。數據庫
相關變化的官方說明: http://www.oracle.com/technetwork/java/javase/7u51-relnotes-2085002.htmlapache
解決辦法:api
須要在$JAVA_HOME/jre/lib/security文件夾下的java.policy文件中相應位置添加一行(可能須要管理員權限才能修改該文件),以容許綁定相應端口:安全
grant { ... permission java.net.SocketPermission "localhost:1527", "listen,resolve"; }
附:報錯的具體內容,和個人java版本服務器
C:\Users\**>java -version java version "1.7.0_51" Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) C:\Users\**>java -jar %DERBY_HOME%\lib\derbyrun.jar server start Fri Feb 14 21:01:07 CST 2014 : 已使用基本服務器安全策略安裝了 Security Manager。 Fri Feb 14 21:01:12 CST 2014 : access denied ("java.net.SocketPermission" "local host:1527" "listen,resolve") java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve") 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.checkListen(Unknown Source) at java.net.ServerSocket.bind(Unknown Source) at java.net.ServerSocket.<init>(Unknown Source) at javax.net.DefaultServerSocketFactory.createServerSocket(Unknown Sourc e) at org.apache.derby.impl.drda.NetworkServerControlImpl.createServerSocke t(Unknown Source) at org.apache.derby.impl.drda.NetworkServerControlImpl.access$000(Unknow n Source) at org.apache.derby.impl.drda.NetworkServerControlImpl$1.run(Unknown Sou rce) at org.apache.derby.impl.drda.NetworkServerControlImpl$1.run(Unknown Sou rce) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(Unk nown Source) at org.apache.derby.impl.drda.NetworkServerControlImpl.executeWork(Unkno wn Source) at org.apache.derby.drda.NetworkServerControl.main(Unknown Source) at org.apache.derby.iapi.tools.run.main(Unknown Source)