我在使用netbeans时遇到问题,我试图启动Java DB。它给我一个访问被拒绝的错误。经过一些研究,我发现这个Unable to start derby database from Netbeans 7.4提供了修复。我试图编辑java策略文件,但我无法打开java.policy文件,因为我不确定如何。我也发现了这个,它说明了如何打开poicy文件http://docs.oracle.com/javase/tutorial/security/tour2/wstep1.html但是当我在命令行输入策略工具时,没有任何东西弹出。
这是我一直收到的错误
Mon Jan 27 13:09:48 EST 2014 : Security manager installed using the Basic server security policy.
Mon Jan 27 13:09:48 EST 2014 : access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkListen(SecurityManager.java:1134)
at java.net.ServerSocket.bind(ServerSocket.java:375)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
at org.apache.derby.impl.drda.NetworkServerControlImpl.createServerSocket(Unknown Source)
at org.apache.derby.impl.drda.NetworkServerControlImpl.access$000(Unknown Source)
at org.apache.derby.impl.drda.NetworkServerControlImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(Unknown Source)
at org.apache.derby.impl.drda.NetworkServerControlImpl.executeWork(Unknown Source)
at org.apache.derby.drda.NetworkServerControl.main(Unknown Source)
答案 0 :(得分:1)
我在Mac上(运行OSX Mavericks,JDK 1.7 update 51和Glassfish 4.0),我遇到了无法编辑文件的问题。所以我做了以下事情:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/security/
sudo vim java.policy
a
// permission for Glassfish 4.0 deployment
permission java.net.SocketPermission "localhost:1527", "listen";
:wq
答案 1 :(得分:0)
确保在尝试编辑之前备份策略文件:)
策略文件只是一个文本文件。你可以编辑java源文件(带文本编辑器的I.E.)。请记住,首先备份文件(安全地播放)。
希望有所帮助:)