Deploying on Ubuntu 24.04

Last modified by D Tim Cummings on 2024/07/16 07:07

These are the steps used to set up a WebObjects deployment environment on Ubuntu 24.04 with Java 21. It does not install WebObjects or any frameworks because it is assumed they are bundled with any apps you deploy. Change the environment variables in the first step if you want different install location or different user that will run the WebObjects applications.  Regardless, you will have to at least change SERVER_NAME and SERVER_IP which are only examples and ones you would never use in practice.

Set environment variables for your configuration to be used in following scripts

For example

export SERVER_NAME=woserver.example.com
export SERVER_IP=172.5.4.3
export WEBOBJECTS_GROUP=webobjects
export WEBOBJECTS_USER=webobjects
export NEXT_ROOT=/opt/webobjects
export URL_PART=apps

The default behaviour is for URL_PART to be "cgi-bin". I prefer to use "apps" in my WebObjects URLs.

Install Java 21

sudo apt install openjdk-21-jdk-headless

At time of writing this was build 21.0.3+9-Ubuntu-1ubuntu1.

Add user and group

sudo groupadd $WEBOBJECTS_GROUP
sudo useradd -m -g $WEBOBJECTS_GROUP -s /bin/bash $WEBOBJECTS_USER
echo -e "export NEXT_ROOT=$NEXT_ROOT" | sudo tee /home/$WEBOBJECTS_USER/.bash_profile

Create directories

sudo mkdir -p /var/log/webobjects
sudo mkdir -p /etc/WebObjects/wotaskd
sudo mkdir -p /etc/WebObjects/JavaMonitor

Create configuration files

cat <<EOF | sudo tee /etc/default/webobjects
WEBOBJECTS_GROUP=$WEBOBJECTS_GROUP
WEBOBJECTS_USER=$WEBOBJECTS_USER
NEXT_ROOT=$NEXT_ROOT
JAVA_MONITOR_ARGS="-WOPort 56789"
WEBOBJECTS_URL=
EOF

cat <<EOF | sudo tee /etc/WebObjects/Properties
er.extensions.WOHostUtilities.localhostips=($SERVER_IP)
WOHost=$SERVER_IP
EOF

echo -e "WOHost=$SERVER_IP" | sudo tee /etc/WebObjects/wotaskd
echo -e "WOHost=$SERVER_IP" | sudo tee /etc/WebObjects/JavaMonitor

Set permissions

sudo chown -R $WEBOBJECTS_USER:$WEBOBJECTS_GROUP /var/log/webobjects
sudo chown -R $WEBOBJECTS_USER:$WEBOBJECTS_GROUP /etc/WebObjects

Install wotaskd and javamonitor from project wonder

sudo mkdir -p $NEXT_ROOT/Local/Library/WebObjects/Applications
sudo mkdir -p $NEXT_ROOT/Local/Library/WebObjects/JavaApplications
cd $NEXT_ROOT/Local/Library/WebObjects/JavaApplications

sudo wget https://jenkins.wocommunity.org/job/Wonder7/lastSuccessfulBuild/artifact/Root/Roots/wotaskd.tar.gz
sudo tar zpxf wotaskd.tar.gz
sudo rm wotaskd.tar.gz

sudo wget https://jenkins.wocommunity.org/job/Wonder7/lastSuccessfulBuild/artifact/Root/Roots/JavaMonitor.tar.gz
sudo tar zpxf JavaMonitor.tar.gz
sudo rm JavaMonitor.tar.gz

sudo chown -R $WEBOBJECTS_USER:$WEBOBJECTS_GROUP $NEXT_ROOT/Local
sudo mkdir -p $NEXT_ROOT/bin
cd $NEXT_ROOT/bin
sudo ln -s $NEXT_ROOT/Local/Library/WebObjects/JavaApplications/wotaskd.woa/wotaskd
sudo ln -s $NEXT_ROOT/Local/Library/WebObjects/JavaApplications/JavaMonitor.woa/JavaMonitor javamonitor

# Fix wotaskd and javamonitor to work with Java 17 if not already
sudo sed -i '2s/= $/= --add-exports=java.base\/sun.security.action=ALL-UNNAMED/' $NEXT_ROOT/Local/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/UNIX/UNIXClassPath.txt
sudo sed -i '2s/= $/= --add-exports=java.base\/sun.security.action=ALL-UNNAMED/' $NEXT_ROOT/Local/Library/WebObjects/JavaApplications/javamonitor.woa/Contents/UNIX/UNIXClassPath.txt

Create services for wotaskd and javamonitor

cat <<EOF | sudo tee /lib/systemd/system/wotaskd.service
[Unit]
Description=WebObjects/Wonder wotaskd
Documentation=https://wiki.wocommunity.org/display/documentation/Wonder+JavaMonitor+and+wotaskd
AssertPathExists=/var/log/webobjects
AssertPathExists=$NEXT_ROOT/Local/Library/WebObjects/JavaApplications/wotaskd.woa
After=network.target
[Service]
User=$WEBOBJECTS_USER
Group=$WEBOBJECTS_GROUP
Environment=NEXT_ROOT=$NEXT_ROOT
Environment="JVM_OPTIONS=-Xms32m -Xmx64m -XX:NewSize=2m"
ExecStart=$NEXT_ROOT/Local/Library/WebObjects/JavaApplications/wotaskd.woa/wotaskd -WOPort 1085 -Xms32m -Xmx64m >> /var/log/webobjects/wotaskd.log 2>&1
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF

cat <<EOF  | sudo tee /lib/systemd/system/javamonitor.service
[Unit]
Description=WebObjects/Wonder JavaMonitor
Documentation=https://wiki.wocommunity.org/display/documentation/Wonder+JavaMonitor+and+wotaskd
AssertPathExists=/var/log/webobjects
AssertPathExists=$NEXT_ROOT/Local/Library/WebObjects/JavaApplications/JavaMonitor.woa
After=wotaskd.service
[Service]
User=$WEBOBJECTS_USER
Group=$WEBOBJECTS_GROUP
Environment=NEXT_ROOT=$NEXT_ROOT
Environment="JVM_OPTIONS=-Xms32m -Xmx64m -XX:NewSize=2m"
ExecStart=$NEXT_ROOT/Local/Library/WebObjects/JavaApplications/JavaMonitor.woa/JavaMonitor -WOPort 56789 -Xms32m -Xmx64m >> /var/log/webobjects/javamonitor.log 2>&1
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload

sudo systemctl enable wotaskd
sudo systemctl start wotaskd
sudo systemctl status wotaskd

sudo systemctl start javamonitor
sudo systemctl status javamonitor

Install Apache HTTP Server (MPM prefork)

sudo apt install apache2 make apache2-dev -y
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo a2enmod expires
sudo a2enmod ssl
sudo a2enmod rewrite

# Add ServerName to conf to avoid configtest errors
echo "ServerName $SERVER_NAME" | sudo tee /etc/apache2/conf-available/server-name.conf
sudo a2enconf server-name

# Install WebObjects adaptor
git clone https://github.com/wocommunity/wonder.git
cd wonder/Utilities/Adaptors
sed -i '107s/CGI Apache2.2/Apache2.4/' make.config
sed -i '9s/MACOS/LINUX/' make.config
make
cd Apache2.4
sudo apxs -i -a -n WebObjects mod_WebObjects.la
sudo cp apache.conf /etc/apache2/mods-available/WebObjects.conf
sudo sed -i "7s/^LoadModule/# LoadModule/" /etc/apache2/mods-available/WebObjects.conf
sudo sed -i "15,18s/cgi-bin/$URL_PART/" /etc/apache2/mods-available/WebObjects.conf
sudo sed -i "38s/localhost/$SERVER_IP/" /etc/apache2/mods-available/WebObjects.conf
sudo a2enmod WebObjects

# Create Apache virtual host
sudo mkdir -p /var/www/$SERVER_NAME
sudo mkdir -p $NEXT_ROOT/Local/Library/WebServer/Documents/WebObjects
sudo ln -s $NEXT_ROOT/Local/Library/WebServer/Documents/WebObjects /var/www/$SERVER_NAME/WebObjects

cat <<EOF  | sudo tee /etc/apache2/sites-available/$SERVER_NAME.conf
<VirtualHost *:80>
  ServerName
$SERVER_NAME
 DocumentRoot /var/www/$SERVER_NAME
 <Directory />
   Require all denied
 </Directory>
 <Directory /var/www/$SERVER_NAME/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
 </Directory>
 <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/html "access 5 minutes"
 </IfModule>
  ErrorLog ${APACHE_LOG_DIR}/error_apps_$SERVER_NAME.log
  CustomLog ${APACHE_LOG_DIR}/access_apps_$SERVER_NAME.log combined
</VirtualHost>
EOF

sudo a2ensite $SERVER_NAME.conf

sudo apachectl configtest
sudo systemctl restart apache2

Troubleshooting

# To test WOAdaptorInfo edit /etc/apache2/mods-available/WebObjects.conf and uncomment
WebObjectsAdminUsername public

#restart apache2
sudo systemctl restart apache2

#check in browser
http://woserver.example.com/apps/WebObjects/WOAdaptorInfo

#to turn on woadaptor logging
touch /tmp/logWebObjects

#might need to mkdir for adaptor logging
mkdir /Library
chown $WEBOBJECTS_USER:$WEBOBJECTS_GROUP /Library