Share on Social Media

Discover how to install TomEE on Linux 7 with our comprehensive guide. Get step-by-step instructions, setup tips, and troubleshooting advice for a smooth installation. #centlinux #linux #java

What is Apache TomEE?

Apache TomEE (pronounced “Tommy”) is the Java Enterprise Edition of Apache Tomcat. Apache TomEE combines several Java enterprise projects including Apache OpenEJB, Apache OpenWebBeans, Apache OpenJPA, Apache MyFaces, etc. In comparison with Apache Tomcat, Apache TomEE is loaded with more technology support. According to Wikipedia, TomEE = Tomcat + JavaEE.

Apache TomEE is built on top of Apache Tomcat, adding Java EE features to provide a comprehensive platform for developing and deploying enterprise-level Java applications. Here are some key features and aspects of Apache TomEE:

Key Features

Java EE Compatibility:

  • Java EE Features: TomEE extends Tomcat by including a set of Java EE APIs, such as Servlets, JavaServer Pages (JSP), Enterprise JavaBeans (EJB), Java Message Service (JMS), Contexts and Dependency Injection (CDI), and Java Persistence API (JPA). This makes TomEE a full-featured application server capable of running enterprise applications.

Based on Apache Tomcat:

  • Tomcat Foundation: Apache TomEE builds on the robust, well-established foundation of Apache Tomcat, leveraging its core capabilities while adding additional enterprise-level features.

Open Source:

  • Community-Driven: TomEE is open-source software with an active community contributing to its development and maintenance. It is free to use and distribute.

Lightweight and Efficient:

  • Performance: TomEE is designed to be lightweight and efficient, making it suitable for a wide range of applications from small-scale projects to large enterprise systems.

Modular Architecture:

  • Flexible Deployment: TomEE offers a modular architecture that allows you to include or exclude Java EE features based on your application’s needs.

Management and Monitoring:

  • Administration Tools: TomEE provides various management and monitoring tools, including a web-based management console and command-line utilities for administrative tasks.

Development and Deployment:

  • IDE Integration: TomEE integrates with popular Integrated Development Environments (IDEs) like Eclipse and IntelliJ IDEA, offering tools and plugins for efficient development and deployment.

Clustering and High Availability:

  • Scalability: TomEE supports clustering and load balancing features to help you build scalable and highly available applications.

Use Cases for Apache TomEE

  • Enterprise Applications: Ideal for deploying complex enterprise-level Java applications requiring a full Java EE stack.
  • Web Applications: Suitable for developing and hosting dynamic web applications.
  • Microservices: Can be used for building microservices architectures with Java EE technologies.

Common Components in TomEE

  • Tomcat: The core servlet container.
  • Java EE APIs: EJB, CDI, JPA, JMS, etc.
  • Jasper: JSP Engine.
  • Catalina: The servlet container.

TomEE Editions

Apache TomEE comes in several editions to cater to different needs:

  • TomEE Web Profile: A lightweight profile suitable for web applications.
  • TomEE Plus: Includes additional Java EE features for more complex applications.
  • TomEE Full: Contains the complete Java EE stack for comprehensive enterprise needs.

Example Use Cases

  • Enterprise Resource Planning (ERP) systems.
  • Customer Relationship Management (CRM) applications.
  • E-commerce platforms.
  • Content Management Systems (CMS).

Comparison with Other Servers

FeatureApache TomEEApache TomcatWildFlyGlassFish
Java EE SupportYesNoYesYes
LightweightYesYesNoNo
Enterprise ReadyYesNoYesYes
Open SourceYesYesYesYes
Tomee Comparison Chart

Apache TomEE is a versatile and powerful solution for developers and organizations looking to build and manage Java EE applications efficiently.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

745772 0021

Application Server Specification

In this article, we will install Apache TomEE 8 on CentOS 7 server and configure Application Manager.

We have provision a CentOS 7 virtual machine with following specifications.

  • Hostname – tomee-01.example.com
  • IP Address – 192.168.116.145/24
  • Operating System – CentOS 7.6
  • Apache TomEE – 8

Install OpenJDK on CentOS 7

Apache TomEE requires Java 8 (or above) runtime environment. Therefore, we are installing OpenJDK 8 on our CentOS 7 server.

# yum install -y java-1.8.0-openjdk-devel

Java executables have been automatically added to PATH environment variable. Therefore, we are only required to set the JAVA_HOME environment variable.

# echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64" >> /etc/profile
# . /etc/profile
# env | grep JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64

Verify Java version.

# java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

OpenJDK 8 has been installed on our CentOS 7 server.

Install TomEE on Linux 7

Create a user to own Apache TomEE software.

# useradd -s /sbin/nologin tomcat

Go to Apache TomEE website to download it.

There are many distributions of Apache TomEE are available. Download your required Apache TomEE distribution from this page.

We are downloading Apache TomEE webprofile. But the installation steps are exactly same for other distributions like Apache TomEE plus, Apache TomEE plume, etc.

Note: There is a good comparison of Apache TomEE distributions is available on their website, that will help you selection of your required Apache TomEE distribution.

# wget https://www-eu.apache.org/dist/tomee/tomee-8.0.0-M2/apache-tomee-8.0.0-M2-webprofile.tar.gz
--2019-03-04 23:00:23--  https://www-eu.apache.org/dist/tomee/tomee-8.0.0-M2/apache-tomee-8.0.0-M2-webprofile.tar.gz
Resolving www-eu.apache.org (www-eu.apache.org)... 95.216.24.32, 2a01:4f9:2a:185f::2
Connecting to www-eu.apache.org (www-eu.apache.org)|95.216.24.32|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 41727556 (40M) [application/x-gzip]
Saving to: âapache-tomee-8.0.0-M2-webprofile.tar.gzâ

100%[======================================>] 41,727,556   234KB/s   in 3m 0s

2019-03-04 23:03:23 (226 KB/s) - âapache-tomee-8.0.0-M2-webprofile.tar.gzâ saved [41727556/41727556]

Extract downloaded file.

# tar xf apache-tomee-8.0.0-M2-webprofile.tar.gz

Move extracted directory to /opt/tomee/.

# mkdir /opt/tomee
# mv apache-tomee-webprofile-8.0.0-M2/ /opt/tomee/

Change ownership of /opt/tomee directory.

# chown -R tomcat:tomcat /opt/tomee/

We will create a soft link latest for /opt/tomee/apache-tomee-webprofile-8.0.0-M2 directory. So, we can upgrade/downgrade Apache TomEE conveniently.

# ln -s /opt/tomee/apache-tomee-webprofile-8.0.0-M2 /opt/tomee/latest

Create a systemd unit file to define a service for Apache TomEE 8 server.

# vi /usr/lib/systemd/system/tomee.service

and add following lines therein.

[Unit]
Description=TomEE 8 servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

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

Environment="CATALINA_BASE=/opt/tomee/latest"
Environment="CATALINA_HOME=/opt/tomee/latest"
Environment="CATALINA_PID=/opt/tomee/latest/temp/tomee.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/opt/tomee/latest/bin/startup.sh
ExecStop=/opt/tomee/latest/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

Execute following command to notify systemd that we have created a new unit file.

# systemctl daemon-reload

Start and enable Apache TomEE service.

# systemctl enable tomee.service
Created symlink from /etc/systemd/system/multi-user.target.wants/tomee.service to /usr/lib/systemd/system/tomee.service.
# systemctl start tomee.service

Allow Apache TomEE service port in Linux firewall.

# firewall-cmd --permanent --add-port=8080/tcp
success
# firewall-cmd --reload
success

Browse URL http://tomee-01.example.com:8080/ in a client’s browser.

Apache TomEE Default Page 1
Apache TomEE Default Page 1

Apache TomEE 8 has been installed on CentOS 7.

Configure Apache TomEE Application Manager

Application Manager provides Web UI to easily manage, deploy, start and stop Java applications running on Apache TomEE 8 server. It is installed with Apache TomEE but requires some necessary settings prior to use.

Define users and roles to access Apache TomEE 8 Manager Web UI.

# vi /opt/tomee/latest/conf/tomcat-users.xml

Add following lines just before </tomcat-usersgt; tag.

   <role rolename="admin-gui"/>
   <role rolename="manager-gui"/>
   <user username="admin" password="admin" roles="admin-gui,manager-gui"/>
   <user username="ahmer" password="123" roles="admin-gui,manager-gui"/>

By default Application Manager is allowed to be accessed from localhost only.

We must edit the following files to let us access it from other machines.

# vi /opt/tomee/latest/webapps/manager/META-INF/context.xml

Find following lines of code and add the IP address of the client system, that you are using for Apache TomEE administration.

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127.d+.d+.d+|::1|0:0:0:0:0:0:0:1" />

Our client’s IP address is 192.168.116.1/24. Therefore, after adding it in the above file, the final code is looks like following.

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127.d+.d+.d+|::1|0:0:0:0:0:0:0:1|192.168.116.1" />

Similarly, repeat the above step for following file.

# vi /opt/tomee/latest/webapps/host-manager/META-INF/context.xml

Restart Apache TomEE 8 service to apply changes.

# systemctl restart tomee.service

Browse URL http://tomee-01.example.com:8080 using a client’s browser.

Apache TomEE Default Page 2
Apache TomEE Default Page 2

Click on Server Status.

Apache TomEE Server Status
Apache TomEE Server Status

Go back and click on Manager App.

Tomcat Web Application Manager
Tomcat Web Application Manager

Go back and click on Host Manager.

Tomcat Virtual Host Manager
Tomcat Virtual Host Manager

Application Manager has been configured on Apache TomEE 8 running on CentOS 7 server.

If you are new to Linux and facing difficulty in working at Linux Bash prompt. We recommend that, you should read The Linux Command Line, 2nd Edition: A Complete Introduction by William Shotts.

Final Thoughts

Setting up Apache TomEE on Linux 7 can be a smooth process with the right approach and attention to detail. I hope this guide helps you successfully install and configure TomEE for your Java applications. If you need further assistance or run into any issues, I’m here to help. Check out my Fiverr gig for expert support with TomEE installations, configurations, and more: Linux Server Administrator

Feel free to reach out for personalized solutions and ensure your TomEE setup is done right and efficiently!

4 thoughts on “How to install TomEE on Linux 7”
  1. this message was given when i tried to start the service.
    Job for tomee.service failed because the control process exited with error code.
    See "systemctl status tomee.service" and "journalctl -xe" for details.

Leave a Reply