Wednesday, 25 June 2014

Unable to Startup Derby database - java.net.SocketPermission

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.

C:\glassfish4\glassfish\bin\asadmin start-domain domain1
C:\glassfish4\glassfish\bin\asadmin start-database


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.

%JAVA_HOME%\jre\lib\security\java.policy

grant {
    permission java.net.SocketPermission "localhost:1525", "listen";
};

C:\glassfish4\glassfish\bin>asadmin start-domain
Waiting for domain1 to start ...................................................
........................................................
Successfully started the domain : domain1
domain  Location: C:\glassfish4\glassfish\domains\domain1
Log File: C:\glassfish4\glassfish\domains\domain1\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.

C:\glassfish4\glassfish\bin>asadmin start-domain
Waiting for domain1 to start ...................................................
........................................................
Successfully started the domain : domain1
domain  Location: C:\glassfish4\glassfish\domains\domain1
Log File: C:\glassfish4\glassfish\domains\domain1\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.
...
...
...
Starting database in the background.
Log redirected to C:\glassfish4\glassfish\databases\derby.log.
Command start-database executed successfully.



No comments:

Post a Comment