3

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)
Community
  • 1
  • 1
user3241544
  • 61
  • 2
  • 5

2 Answers2

1

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
Ricardo
  • 3,696
  • 5
  • 36
  • 50
openrory
  • 61
  • 6
0

Make sure you back up the policy file before attempting to edit :)

The policy file is just a text file. You would edit like you would a java source file (I.E. with a text editor). Remember, make a backup of the file first (play it safe).

Hope that helps:)

lorinpa
  • 556
  • 1
  • 5
  • 6
  • Can you post the "access denied error"? What is being denied, using a port? access to a directory? ability to execute something? login in to the database? You didn't specify what is denied. You hinted, but you did not specify. Thus best to post the actual error message (relevant portion) . :) – lorinpa Jan 27 '14 at 19:06
  • Okay so I got it open with a text editor but im not sure wherre to stick this line, permission java.net.SocketPermission "localhost:1527", "listen"; Can i just put it at the end? – user3241544 Jan 27 '14 at 19:58
  • The position within "grants {....}" doesn't matter. What matters is, are you replacing a line. In other words do you already have a an entry for "permission java.net.SocketPermission". If so, you want to replace the parameters (replace the line with your new setting). You don't want 2 grant statements for the same java.net.SocketPermission. Does that make sense :) – lorinpa Jan 27 '14 at 20:27
  • I attempted to edit the documnet in WordPad but it says access denied when i try saving the chagnes – user3241544 Jan 28 '14 at 02:49
  • Thank you for the response. However, you need to specify what "access denied" means. I'll guess it means, your current OS user (account you are logged in to as) is not permitted write access to that file. If that is correct, you need to determine the access control list (ACL) for the file, then login with appropriate permissions. It's still just a text file. Thus, I answered your original question, right :) – lorinpa Jan 28 '14 at 14:18