You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by BARDUBITZKI Software <so...@bardubitzki.com> on 2005/08/03 17:49:52 UTC

Derby and Tomcat-5.5.9

Hi all,

my web app used derby as DB and it seems to be working fine. From time
to time Tomcat-5.5.9 is hanging for some strange reason. My ISP believes
that this issue is caused by memory leaks in the VM( my web app and
tomcat are running in its own VM on the server). 
That the comment:


> ... It often stems from memory leaks in their Java code (creating
> objects and never removing them from memory), code that doesn't handle
> database restarts gracefully (keep trying to use closed connections
> without recreating the pool) ...

I checked my code, but it seems to be o.k.

1. Question:

Has somebody experienced similar problems by using Derby?

2. Question:

Because the problem happens quite frequently we are monitoring tomcat
with the following script:

#!/bin/sh
if [ -f /var/run/primary ]; then

   if [ -f $HOME/catalinamonitor ]; then
      echo JVM failed;
      export JAVA_HOME=/usr/java/jdk1.5.0
      $HOME/jakarta-tomcat/bin/shutdown.sh
      $HOME/jakarta-tomcat/bin/startup.sh
      rm -f $HOME/catalinamonitor
      exit 1
   fi

   touch $HOME/catalinamonitor

   wget -O /dev/null -q http://bardubitzki.com
   retcode=$?

   rm -f $HOME/catalinamonitor

   if [ $retcode -ne 0 ]; then
      echo JVM failed;
      export JAVA_HOME=/usr/java/jdk1.5.0
      $HOME/jakarta-tomcat/bin/shutdown.sh
      $HOME/jakarta-tomcat/bin/startup.sh
      exit 1;
   fi
fi

The startup.sh looks like that:

#!/bin/sh
#
-----------------------------------------------------------------------------
# Start Script for the CATALINA Server
#
# $Id: startup.sh,v 1.4 2004/11/17 20:17:46 yoavs Exp $
#
-----------------------------------------------------------------------------
# Better OS/400 detection: see Bugzilla 31132
os400=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
esac

# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '.*/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done
 
PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh

# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are: 
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
    echo "Cannot find $PRGDIR/$EXECUTABLE"
    echo "This file is needed to run this program"
    exit 1
  fi
fi 

exec "$PRGDIR"/"$EXECUTABLE" start "$@"

CLOUDSCAPE_INSTALL= omitted!

export
CLASSPATH="${CLOUDSCAPE_INSTALL}/lib/derby.jar:${CLOUDSCAPE_INSTALL}/lib/derbytools.jar:${CLOUDSCAPE_INSTALL}/lib/derbynet.jar:${CLASSPATH}"

[ -z "$CLASSPATH" ] && {   .
"$CLOUDSCAPE_INSTALL"/frameworks/NetworkServer/bin/setNetworkServerCP.ksh }

java org.apache.derby.drda.NetworkServerControl start -p 8352



The problem here is that tomcat can't verify the JDBCRealms defined in
the server.xml at start up, because Derby is not running. On the other
hand if we start first Derby tomcat wouldn't start up.

Has somebody a solution for that problem?

Any help is much appreciated.

Stephan