Things that went wrong


Things that for some reason went wrong

This section is to store notes about things that for some reason went wrong and I didn't have enough time to debug.
JSVC deamon is one of them. Almost everything run well with the exception of Jenkins CI server. When I tried to install jenkins.war, it freezed after the begin of jenkins deploy without trace of what was happening, no log error, no nothing. It seems to be waiting for something but I couldn't figure out what.
Next instructions are correct, Pentaho run whitout problems, I just changed the installation process to be able to run jenkins together.


JSVC Daemon - Run Tomcat as a UNIX service

To start Tomcat at boot time, we will use jsvc to daemonize Tomcat.

Two things need our attention:
  • On Mac OS X, the default (client) jvm is 32-bit only, you need to add -jvm server clausule on daemon.sh script to guarantee a full 64-bit jvm. Otherwise, you will get the following error:
    "Cannot dynamically link to /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libclient.dylib dlopen(/System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libclient.dylib, 10): no suitable image found. Did find: /System/Library/Frameworks/JavaVM.framework/Home/../Libraries/libclient.dylib: mach-o, but wrong architecture"
  • We need to define the WorkingDirectory in the tomcat-plist file, because Pentaho will use it.
Unpack the java server daemon JSVC
The Java Server Daemon JSVC source code is included with the Tomcat 7.0.x binary release.

# Change directories to the Tomcat home directory
cd $CATALINA_HOME/bin

# Unpack the jsvc archive
tar -xvzf commons-daemon-native.tar.gz 

# Change directories to the unpacked source directory
cd commons-daemon-1.0.9-native-src/unix
Compile JSVC
Execute the following commands to build the jsvc daemon and copy the daemon executable and startup script to the Tomcat bin directory.
The OS X developer tools must be installed.


# To be able to build the 64-binaries for supported platforms enter the
# specific parameters before calling configure

export CFLAGS='-arch x86_64'
export LDFLAGS='-arch x86_64'

# Create the configure file
support/buildconf.sh

# Create the make file (JAVA 6)
./configure --with-java=/System/Library/Frameworks/JavaVM.framework/Home/ --with-os-type=../  

# Build jsvc
make

# Move jsvc into bin
mv jsvc ../..


# In previous versions of commons-daemon, there was an script (Tomcat7.sh),
# located in samples folder which helps to start Tomcat as a service.
# Since 1.0.8 version, this script was moved to tomcat/bin folder with the name of daemon.sh

Edit the daemon startup script daemon.sh

# Edit daemon.sh
cd $CATALINA_HOME/bin
nano daemon.sh

# Add this lines at the beginning of the file, right after the copyright comments.
# Make sure the following environment variables are set correctly in
# the daemon.sh startup script for your installation. It is recommended that you run
# Tomcat as a user other than root as to restrict Tomcat's access to the host machine. 
# Change <username> with the apropiate value (your user name, for example).

JAVA_HOME=/Library/Java/Home
CATALINA_HOME=/opt/servers/Tomcat/TomcatHome
DAEMON_HOME=$CATALINA_HOME/bin
TOMCAT_USER=<username>

# for multi instances adapt those lines.
# TMP_DIR=/var/tmp
# PID_FILE=/var/run/jsvc.pid
# CATALINA_BASE=$CATALINA_HOME

# Set values appropriate for Pentaho
CATALINA_OPTS="-Xms256m -Xmx1024m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

# If you want to debug, un-comment the next line
# CATALINA_OPTS=$CATALINA_OPTS " -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"

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

...


# Fix BZ52750 bug. Correctly parse command options
# In the first "for" statement that appears, 
# change from:
# for o
#
# to
# while [ ".$1" != . ]
#
# And change from:
#  case "$o" in
#
# to
#   case "$1" in
#
# Next version of tomcat this will not be necessary.
# The full statements must read:
...
DIRNAME="`dirname $ARG0`"
PROGRAM="`basename $ARG0`"
while [ ".$1" != . ]
do
  case "$1" in
    --java-home )
 	JAVA_HOME="$2" 

 
# For each case option (run, start, stop, version) add the following two lines
#      -jvm server \
#      -procname daemon \
# to ensure 64-bit operation and to give a name to the process
# Example:
    run     )
      shift
      "$JSVC" $* \
      $JSVC_OPTS \
      -java-home "$JAVA_HOME" \
      -pidfile "$CATALINA_PID" \
      -jvm server \
      -procname Tomcat7 \
      -wait 10 \
      -nodetach \
      -outfile "&1" \
      -errfile "&2" \
      -classpath "$CLASSPATH" \
      "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
      -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
      -Dcatalina.base="$CATALINA_BASE" \
      -Dcatalina.home="$CATALINA_HOME" \
      -Djava.io.tmpdir="$CATALINA_TMP" \
      $CATALINA_MAIN
      exit $?
    ;;


Start Tomcat as a Daemon
# Execute the startup script to start Tomcat as a daemon
# You must execute the daemon as root as it writes the
# daemon's process id to /var/run.
# If Tomcat is already running, first stop it.
sudo ./daemon.sh start
# Check and see if it is running
ps -ax | grep Tomcat7
...
# Check the version
sudo ./daemon.sh version

Still running according to PID file /opt/servers/Tomcat/TomcatHome/logs/catalina-daemon.pid, PID is 79506
jsvc (Apache Commons Daemon) 1.0.8
Copyright (c) 1999-2011 Apache Software Foundation.
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
commons daemon version "1.0.8"
commons daemon process (id: 79520, parent: 79518)
Server version: Apache Tomcat/7.0.26
Server built:   Feb 17 2012 02:11:27
Server number:  7.0.26.0
OS Name:        Mac OS X
OS Version:     10.7.2
Architecture:   x86_64
JVM Version:    1.6.0_29-b11-402-11M3527
JVM Vendor:     Apple Inc.

# To stop the server ...
sudo ./daemon.sh stop