A Sunny Commune - Cheng's Blog

« Where Location is... | Main | How to Run jbpm on... »

http://blogs.sun.com/chengfang/date/20060321 Tuesday March 21, 2006

Troubles/Help with Derby ksh Scripts (ij.ksh, startNetworkServer.ksh, setNetworkClientCP.ksh, dblook.ksh, NetworkServerControl.ksh)


I usually use SJSAS/Glassfish asadmin to start and stop derby: asadmin start-database, asadmin stop-database.  I can also use NetBeans 5.0 to manage it in a more user-friendly way.  Yesterday when I ran Derby ksh scripts directly on Solaris, I had quite a few troubles.  I know I am not the first one who has to wrestle with it.  Put a note here for reference.

Symptoms

Reasons

Solutions

My Questions/Suggestions to Derby

CLASSPATH: Undefined variable.

Derby ksh scripts don't have the first line declaration (#! /usr/bin/ksh).  When you run these ksh scripts, the default /bin/sh is used to run them.  Of course, /bin/sh doesn't understand some ksh syntax used there.  Therefore CLASSPATH is not set by the script.  See this discussion.

1.run them with ksh (e.g., ksh ij.ksh);

2. or add to all ksh scripts:
#! /usr/bin/ksh

1. Why not use /bin/sh for maximum portability?  /bin/sh is less powerful than ksh, but these scripts are just a few simple steps.

2. As a good practice, do not use CLASSPATH environment variable.  Use -classpath option to java command.

./ij.ksh[17]: /frameworks/NetworkServer/bin/setNetworkClientCP.ksh:  not found

DERBY_INSTALL environment variable not set

In csh/tcsh:

setenv DERBY_INSTALL /file/sjsas/derby

In bash/ksh:

export DERBY_INSTALL=/file/sjsas/derby

1. Why not use some default? something like ../../.. should be sufficient in most cases.

2. Why not check if it has been set or not, then fail with more helpful message?

startNetworkServer.ksh[55]: /usr/java/bin/java: not found

JAVA_HOME environment variable not set. The default JAVA_HOME used here is /usr/java

Set it

Log a warning/info message: JAVA_HOME not set, using the default one.

still not working, and you don't want to spend one more minute on it.

Users get frustrated  

run java command directly.  For example, to shutdown derby:
java -classpath ../../../lib/derbyclient.jar:../../../lib/derbytools.jar:../../../lib/derbynet.jar:../../../lib/derby.jar org.apache.derby.drda.NetworkServerControl shutdown

Or you can set the CLASSPATH environment variable in $HOME/.derby and source it when you start a new terminal. Then you can java without specifying the long -classpath.

1. Add an ant build.xml for to invoke all these java classes.

2. Add perl version of these scripts.

3. Add python version of these scripts.

As a side, when I first heard someone mentioning ij.ksh, I thought it was a launch script for IntelliJ.  As you can see, I'm not an IntelliJ user.  I still don't know whey it was so named, maybe stands for interactive javadb?

technorati tags: , ,

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed