Unable to Startup Derby database – java.net.SocketPermission
Here in this article we will try to resolve an issue related to Derby Database startup due to SocketPermission exception on a Windows OS.
Test Environment
OS – Windows
JDK – 1.7 update 55
JRE – 1.7 update 55
Glassfish Server – 4.0 (Open source edition)
Issue
Unable to startup the default derby database provided with the glassfish application server. The database was unable to open the default 1527 port for database.
As per some search on google it was a bug in JDK 1.7 update 51.that has been resolved now. But i was facing similar kind of issue with JDK 1.7 update 55 version. It was throwing the below execption when ever i was trying to startup the database.
asadmin start-domain domain1
asadmin start-database
Exception:
Exception - Tue Jun 24 01:21:22 EDT 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(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 Source)
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)
The startup script for database is trying to use the basic security manager (i.e java.policy) setting to startup the database but it was missing the below grant permission in the update 51.
permission java.net.SocketPermission "localhost:1024-", "listen";
Resolution
I added the below grant permission into the java.policy file available at the below location and was able to startup the database appropriately.
File: %JAVA_HOME%\jre\lib\security\java.policy
grant {
permission java.net.SocketPermission "localhost:1525", "listen";
};
asadmin start-domain
Output:
Waiting for domain1 to start ...................................................
........................................................
Successfully started the domain : domain1
domain Location: C:glassfish4glassfishdomainsdomain1
Log File: C:glassfish4glassfishdomainsdomain1logsserver.log
Admin Port: 4848
Command start-domain executed successfully.
asadmin start-database
Output:
Starting database in the background.
Log redirected to C:glassfish4glassfishdatabasesderby.log.
Command start-database executed successfully.
Hope you enjoyed reading this article. Thank you..
4 COMMENTS