/ Installation  

The secret of successful installing TomEE

Hi there AppWorks fans,

Welcome to a new installment of AppWorks tips.

This guide will help you installing the TomEE application server on our Java supported CentOS VM image. The instance of TomEE is used 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 CentOS 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 for TomEE a specific version is required 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 that is required for our image): TomEE 8 Plus

It gives a list of mirror sites where we can download the correct file from with the command: wget http://mirrors.supportex.net/apache/tomee/tomee-8.0.0-M2/apache-tomee-8.0.0-M2-plus.tar.gz

After the download is done, we need to extract the file: tar xvf apache-tomee-8.0.0-M2-plus.tar.gz

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-8.0.0-M2/ /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-8.0.0-M2/ /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…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 8 servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"

Environment="CATALINA_BASE=/opt/tomee/apache-tomee-plus-8.0.0-M2"
Environment="CATALINA_HOME=/opt/tomee/apache-tomee-plus-8.0.0-M2"
Environment="CATALINA_PID=/opt/tomee/apache-tomee-plus-8.0.0-M2/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-8.0.0-M2/bin/startup.sh
ExecStop=/opt/tomee/apache-tomee-plus-8.0.0-M2/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

Now save the file :w and quit vi with :q

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

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 the role names are is typed in 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 URL’s. 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


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 ‘otadmin’ 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
14
15
16
17
18
19
# .bash_profile

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

# User specific environment and startup programs

JAVA_HOME=/usr/lib/jvm/java-11-openjdk
LIB_PATH=/usr/lib/jvm/java-11-openjdk/lib/server/
PATH=$PATH:$HOME/.local/bin:$HOME/bin:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_PATH
CATALINA_HOME=/opt/tomee/apache-tomee-plus-8.0.0-M2

export JAVA_HOME
export PATH
export LD_LIBRARY_PATH
export CATALINA_HOME

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

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


And 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 in a steady way.

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