Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Edit Java Policy File?

Tags:

java

netbeans

I am having a problem using netbeans in which im trying to start the Java DB. Its giving me an access denied error. After some research i have found this Unable to start derby database from Netbeans 7.4 which provides a fix. I attempted to edit the java policy file but I am unable to open the java.policy file because I am unsure how. I have also found this, which says how to open the poicy file http://docs.oracle.com/javase/tutorial/security/tour2/wstep1.html but when I enter policy tool at command line, nothing pops up.

This is the error i keep recieving

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)
like image 254
user3241544 Avatar asked Nov 23 '25 02:11

user3241544


1 Answers

I'm on a Mac (running OSX Mavericks, JDK 1.7 update 51, and Glassfish 4.0) and I had the same problem being unable to edit the file. So I did the following:

  1. Find your java.policy file in /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/security/
  2. start VIM by typing sudo vim java.policy
  3. Go into file insert mode by typing the Vim command a
  4. add the following code to your permissions: // permission for Glassfish 4.0 deployment permission java.net.SocketPermission "localhost:1527", "listen";
  5. go back to the command mode by pressing the Esc button.
  6. Now save and quit the file by typing :wq
  7. Restart the server and you should be okay
like image 87
openrory Avatar answered Nov 24 '25 14:11

openrory



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!