adam bien's blog

DerbyDB start fails on Docker -- Problem and Solution 📎

An attempt to start DerbyDB 10.10.2.0 delivered with Glassfishv5 or recent Payara (asadmin start-database) will fail with:

 
Starting database in Network Server mode on host 0.0.0.0 and port 1527.
Unable to start database.  Please check log in /glassfish5/glassfish/databases/derby.log.

The derby.log contains the following exceptions:


Thu Jul 06 16:20:06 UTC 2017 : Security manager installed using the Basic server security policy.
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.enterprise.admin.cli.optional.DerbyControl.invokeNetworkServerControl(DerbyControl.java:158)
	at com.sun.enterprise.admin.cli.optional.DerbyControl.main(DerbyControl.java:245)
Caused by: java.lang.ExceptionInInitializerError
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at org.apache.derby.impl.drda.NetworkServerControlImpl.startNetworkServer(Unknown Source)
	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)
	... 6 more
Caused by: java.lang.ClassCastException: java.io.IOException cannot be cast to java.lang.RuntimeException
	at org.apache.derby.iapi.services.io.FileUtil.limitAccessToOwnerViaACLs(Unknown Source)
	at org.apache.derby.iapi.services.io.FileUtil.limitAccessToOwner(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.PBmakeFileHPW(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.derby.impl.services.stream.SingleStream.makeFileHPW(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.createDefaultStream(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.makeStream(Unknown Source)
	at org.apache.derby.impl.services.stream.SingleStream.boot(Unknown Source)
	at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) 
    (...)

The exception is related to the issues: DERBY-6410 and DERBY-6503

Fix: update DerbyDB: recent versions are running on Docker without any issues, checkout docker image: Docklands DerbyDB image.

GlassFish v5, as well as, recent Payara Server (Issue #1738), are delivered with an old DerbyDB version. Thankfully the DerbyDB version can be easily upgraded just by overriding the folders: payara41/javadb glassfish5/javadb with the recent DerbyDB version. See e.g. the Docker image: Payara With DerbyDB.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.