/ Installation  

The secret of successful installing TomEE

Hi there AppWorks fans,

Welcome to a new installment of AppWorks tips.

This guide will help you to install the TomEE application server on our Java supported RHEL VM image. We use the instance of TomEE to host the AppWorks platform.

This post is part of the series for ‘AppWorks installation in 10 great steps’.

This is the list of ingredients we are going to use:

  • The already installed ‘Oracle Virtual Box’ software from the previous post
  • Our Java supported RHEL VM image from the previous post
  • PuTTY (SSH client). Downloaded from: putty.org

Let get right into it…

Start the Oracle VM VirtualBox tooling and start-up our image. Leave the image as is and make a connection with PuTTY.

As for Java, also TomEE required a specific version as the documentation will tell us.

general_001

For TomEE, we first create a tomcat user who owns the installation: sudo useradd -s /sbin/nologin tomcat

Next, we need the URL from where we can download TomEE. This can be found here (for the version 8 we use on our image): TomEE 9.1.3 Plus

It gives a list of mirror sites where we can download the correct file from with the command: wget https://archive.apache.org/dist/tomee/tomee-9.1.3/apache-tomee-9.1.3-plus.tar.gz

After download, we need to extract the file: tar xvf apache-tomee-9.1.3-plus.tar.gz

The OpenText installation manual makes an additional step this time, it has to do with a ‘commons-daemon’ service, and the ‘jsvc’ tool that you need to generate! All these (complex steps) are needed to run tomcat in ‘daemon’ mode which is the Unix way for running TomEE as a service (like in Windows). The documentation is even talking about a ‘known issue’ in that daemon scripts which OpenText fixes with a downloadable zip with the corrected files!?
As we already saw in previous installations we can simply create our own ‘systemctl’ service and start/stop our TomEE with systemctl stop|start tomee like we do for all our services! Automatically enable this service to start on system start-up.

Also, make sure to use a GA version of TomEE. I had too many problems with the M1/M2 (‘Milestone’-releases!)

Why so sure about the GA version? I got an error from historical try-out: Unsupported TomEE version '8.0.0-M2'. Supported: [^8\.0\.[0-9]+$]. Put that information on https://regex101.com/ with input ^8\.0\.[0-9]+$ on test string 8.0.0-M2 and it gives indeed no result! Test string 8.0.0 does give result!

Let’s move it all to a nice location with a service to start/stop it:

  • Create a directory: sudo mkdir /opt/tomee
  • Move the extracted folder: sudo mv apache-tomee-plus-9.1.3/ /opt/tomee/
  • Own the new folder by the ‘tomcat’ user: sudo chown -R tomcat:tomcat /opt/tomee/
  • Make a nice link to it: sudo ln -s /opt/tomee/apache-tomee-plus-9.1.3/ /opt/tomee/latest

Don’t use this link in any other configuration file like the ‘tomee.service’, or the system variables like the CLASSPATH as it fails the whole AppWorks installation…That’s my own experience!

  • Create a cool service for it: sudo vi /usr/lib/systemd/system/tomee.service

Add this content to the new file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[Unit]
Description=TomEE 9 servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-17.0.13.0.11-3.el8.x86_64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"

Environment="CATALINA_BASE=/opt/tomee/apache-tomee-plus-9.1.3"
Environment="CATALINA_HOME=/opt/tomee/apache-tomee-plus-9.1.3"
Environment="CATALINA_PID=/opt/tomee/apache-tomee-plus-9.1.3/temp/tomee.pid"
Environment="CATALINA_OPTS=-Xms1024M -Xmx2048M -server -XX:+UseParallelGC -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dbus.xml.vm.maxsize=2048"

ExecStart=/opt/tomee/apache-tomee-plus-9.1.3/bin/startup.sh
ExecStop=/opt/tomee/apache-tomee-plus-9.1.3/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

Now save and quit the file :wq

Last steps…

  • Reload the services-daemon as we changed it with a new service: systemctl daemon-reload
  • Enable the TomEE service: systemctl enable tomee.service
  • Now the big moment where we all waited for: systemctl start tomee.service

When it’s not starting (in my case), you can try to disable ‘SELinux’. Reboot your VM after this change!

Check if it’s all running fine by browsing with your local machine to the URL: http://192.168.56.107:8080

For log file monitoring use the tail command: sudo tail -f /opt/tomee/latest/logs/catalina.out


Now let’s add tomcat users

Edit the tomcat-users.xml file: sudo vi /opt/tomee/latest/conf/tomcat-users.xml

Add these lines just before the last end-tag </tomcat-users>

1
2
<user username="tomee" password="tomee" roles="admin-gui,manager-gui,tomee-admin" />
<user username="rpc" password="rpc" roles="admin-script,manager-script,manager-jmx" />

Make sure to use the role names correctly; with the ‘-‘ in between!


Make the ‘manager’ and ‘host-manager’ apps available for remote users (like our local machine!)

Create and edit a new file with the name ‘manager.xml’

sudo vi /opt/tomee/latest/conf/Catalina/localhost/manager.xml

Add this content to it

1
2
3
<Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
</Context>

Create and edit a new file with the name ‘host-manager.xml’

sudo vi /opt/tomee/latest/conf/Catalina/localhost/host-manager.xml

Add this content to it

1
2
3
<Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/host-manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
</Context>

Restart tomcat systemctl restart tomee.service and check the result on these URLs. They should both give a pop-up for ‘HTTP Basic authentication’ where you can use the credentials as described in the tomcat-users.xml

  • http://192.168.56.107:8080/host-manager/html
  • http://192.168.56.107:8080/manager/html

Optional task: from the last URL you have the ability to ‘undeploy’ the default ‘docs’ webapp; we don’t need it!


As a final step is the proper way to add the correct environment variables for the TomEE instance.

Edit the ~/.bash_profile again for the ‘sysadmin’ user: vi ~/.bash_profile

The final version should look like this for now:

1
2
3
4
5
6
7
8
9
10
11
12
13
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-17.0.13.0.11-3.el8.x86_64
LIB_PATH=$JAVA_HOME/lib/server
export PATH=$PATH:$HOME/.local/bin:$HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_PATH
export CATALINA_HOME=/opt/tomee/apache-tomee-plus-9.1.3

When done reload your profile via the command: source ~/.bash_profile

Check if it’s all OK via: env | grep tomee


That’s a big ‘DONE’ for this installment of AppWorks tips where we installed TomEE. This instance can now be used for hosting the AppWorks platform we will install in a further step on the series ‘AppWorks installation in 10 great steps’. Next step in to install PostgreSQL database, so we can save data steady.

Let me know what you think in the comments and have a good one for today…See U next time!