Oracle Sun JDK 7 : Derby Server (Java DB) does not start using Glassfish 3.1.2 in Netbeans 7.1.2: Permission denied

Apache Derby

Apache Derby

Assuming you’re using JDK 7 in Linux (Here Ubuntu 12.04 LTS), when deploying a web application on Glassfish 3.1.2 using Netbeans 7.1.2, Derby might likely not start and get ready to receive connections, and this due to an exception thrown (JDK 7 security).
which is:

Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "file.encoding" "read")

You can for now append this permission below to the java policy file that is shipped with JDK 1.7.:
permission java.util.PropertyPermission "file.encoding", "read";

The file should like this:

// Standard extensions get all permissions by default

grant codeBase "file:${{java.ext.dirs}}/*" {
permission java.security.AllPermission;
};

// default permissions granted to all domains

grant {
// Allows any thread to stop itself using the java.lang.Thread.stop()
// method that takes no argument.
// Note that this permission is granted by default only to remain
// backwards compatible.
// It is strongly recommended that you either remove this permission
// from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially unsafe.
// See the API specification of java.lang.Thread.stop() for more
// information.
permission java.lang.RuntimePermission "stopThread";

// allows anyone to listen on un-privileged ports
permission java.net.SocketPermission "localhost:1024-", "listen";

// "standard" properies that can be read by anyone

permission java.util.PropertyPermission "java.version", "read";
permission java.util.PropertyPermission "java.vendor", "read";
permission java.util.PropertyPermission "java.vendor.url", "read";
permission java.util.PropertyPermission "java.class.version", "read";
permission java.util.PropertyPermission "os.name", "read";
permission java.util.PropertyPermission "os.version", "read";
permission java.util.PropertyPermission "os.arch", "read";
permission java.util.PropertyPermission "file.separator", "read";
permission java.util.PropertyPermission "path.separator", "read";
permission java.util.PropertyPermission "line.separator", "read";

permission java.util.PropertyPermission "java.specification.version", "read";
permission java.util.PropertyPermission "java.specification.vendor", "read";
permission java.util.PropertyPermission "java.specification.name", "read";

permission java.util.PropertyPermission "java.vm.specification.version", "read";
permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
permission java.util.PropertyPermission "java.vm.specification.name", "read";
permission java.util.PropertyPermission "java.vm.version", "read";
permission java.util.PropertyPermission "java.vm.vendor", "read";
permission java.util.PropertyPermission "java.vm.name", "read";
permission java.util.PropertyPermission "file.encoding", "read";
};

N.B: The file is found here in our case /usr/lib/jvm/jdk1.7.0/jre/lib/security/java.policy

More info: http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.base.doc%2Finfo%2Faes%2Fae%2Frsec_javapolicy.html

Advertisements

2 thoughts on “Oracle Sun JDK 7 : Derby Server (Java DB) does not start using Glassfish 3.1.2 in Netbeans 7.1.2: Permission denied

  1. Pierre Caron

    Thank you very much for your help on how to allow a permission in the file java.policy.

    I had a similar problem : Glassfish was preventing my web application from deploying because one of the library I used (namely Omnifaces) was requiring an access. I added the following line :

    permission java.lang.reflect.ReflectPermission “suppressAccessChecks”;

    to the file :

    /usr/lib/jvm/jdk1.7.0_21/jre/lib/security/java.policy

    and now it deploys!

    My previous researches lead me to modifying the server.policy file but this was not the cause of my problem.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s