<< JSF and RESTful URLs | Home | Java VIII >>

Embedded Derby on a socket, revisited

In an earlier post in this blog I described how to turn on a listening socket for the embedded Derby that is bundled with GlassFish. That method configures the embedded Derby to behave like the standalone Derby: the listening socket is on port 1527 and Derby's system directory is "/opt/glassfish/databases", just like in the standalone server.

But I have realized that this is not a good thing, for several reasons. One is that applications that use the embedded Derby client will find their databases in a non-standard location. The standard system directory for embedded clients is "/opt/glassfish/domains/domain1/config". This is problematic for applications such as Jackrabbit that create their own files in that directory and expect Derby to use the same directory structure. Another reason why it's bad is that there are initialization issues for applications that use the Derby network client. The network listener is opened when the first embedded database is booted, but this still doesn't make the JDBC resources available early enough in all cases.

So enabling a built-in network listener is no substitute for running a standalone Derby server. However, it is still useful for debugging and maintenance, by allowing you to connect with a client such as ij or SQuirreL. My GlassFish configuration now contains the following extra properties:

    <jvm-options>-Dderby.drda.startNetworkServer=true</jvm-options>
<jvm-options>-Dderby.drda.portNumber=1528</jvm-options>
This starts the network listener but keeps the Derby system directory in the standard place for embedded clients. And it uses port 1528, leaving the standard port 1527 free for use by the standalone Derby. Just put the above lines among the <jvm-options> in the file "domains/domain1/config/domain.xml" (after shutting down GlassFish first of course).

 




Add a comment Send a TrackBack