Unable to Startup Derby database – java.net.SocketPermission

Unable to Startup Derby database – java.net.SocketPermission

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.

Pre-requisities
OS – Windows
JDK – 1.7 update 55
JRE – 1.7 update 55
Glassfish Server – 4.0 (Open source edition)

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:glassfish4glassfishbinasadmin start-domain domain1
C:glassfish4glassfishbinasadmin 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%jrelibsecurityjava.policy

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

C:glassfish4glassfishbin>asadmin start-domain
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.

C:glassfish4glassfishbin>asadmin start-domain
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.



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

comments user
Pramod Kumar

its not working for me. after all this getting same error

comments user
novicejava1

Please check which Java version is active on your system by default and the PATH variable. You need to edit the java.policy file of the respective jre that is active on your system. Check below command and see your PATH to JDK that is being used and edit java.policy file for that.

C:> echo %JAVA_HOME% – You must have set this path variable after installing JDK

There are chances that your System PATH must have having another JRE above and being picked up rather than the JAVA_HOME JRE. You need to figure out that and update the java.policy file for that JRE

comments user
Osama Zien Adden

Thanks .. it was very useful for my case (Oracle BI Publisher 11g trial edition)