If you just heard about TomEE and want to know more, then you’ve come to the right place. This post will guide you on how to start using TomEE for your Java EE project. But wait, what exactly is TomEE?
What is TomEE?
(the long version)
TomEE is assembled from a vanilla Tomcat zipped file with all the additional libraries required to provide a Java EE environment. These include Apache CXF, ActiveMQ, OpenWebBeans and OpenJPA to name a few. This means that if you already use Tomcat and now need EE features, consider TomEE. It integrates easily with Tomcat and cuts down on extra time and work.
Currently, TomEE is a Java EE 6 Web Profile Certified server and working hard to complete the Java EE 7 Web Profile Certification.
(the explanation wasn’t so long, was it?)
Just download the desired version from TomEE website, unzip it and you are good to go! Notice how small it is. Just around 40 Mbytes unpacked. No need to get a separate disk as you would do for a Websphere or a Weblogic installation.
TomEE Directory Layout
The directory layout is similar to Tomcat, but some folders include additional features.
|bin||Directory where startup, shutdown and other scripts are stored.|
|conf||Directory where configuration files are located. These affect the entire server.|
|lib||Directory where libraries are stored, including third party libraries to transform Tomcat into TomEE. Libraries stored here are shared between all applications.|
|logs||Directory where server and application logs are stored.|
|webapps||Directory used to deploy .WAR files.|
|apps||Optional directory to deploy any EE application (EJB, WAR, EAR)|
If you look into the bin/ directory you are going to find several files, but for now, lets just concentrate on:
- startup.sh / startup.bat
- shutdown.sh / shutdown.sh
- catalina.sh / catalina.bat
You can start the server right away just by executing the
startup.(sh|bat) script. TomEE is now running in background mode. To confirm that the server booted up properly, check the file
catalina.out, sitting in the
shutdown.(sh|bat) you can stop the server.
TomEE in Foreground
These commands are mostly used when running production servers. When doing development, we might want to see the server output right away. We can do that using the script
catalina.(sh|bat) run. This starts TomEE in foreground mode and output the server logs to the screen from where you started the server.
In this mode, you can easily stop TomEE by hitting
CTRL|CMD + C.
Try putting the address
http://localhost:8080 in a browser. You should get the Tomcat welcome page. By the way, did you notice how fast the server starts? Just a few seconds, depending on the host machine. For me, it actually starts in less than 1 second!
Note: You can use Java 8 to run TomEE and develop awesome applications using Streams and Lambdas.
Deploy a WAR in TomEE
The easiest way to add and deploy an application to TomEE is to drop the application package into a deployment directory. For that purpose you have available two directories: webapps and apps.
To deploy an Application, just copy the WAR file into the
apps directories. The deploy itself has the same outcome. For simplicity reason and to keep compatibility with Tomcat, we recommend to deploy WAR files in the
It doesn’t matter if TomEE is running or not when you copy the file. If running, TomEE will detect the new file after a second or two, deploy and start the application. If you replace an existing file, TomEE will redeploy the application.
Like with Tomcat, your WAR application
myapp.war will be available at
If you don’t have one, try it out with the well known Java Petstore sample. The Java Petstore was designed to illustrate how Java EE could be used to develop an eCommerce web application. You can download it here.
TomEE is a very lightweight application server. It shouldn’t take you more than 10 minutes (depending on your Internet connection), to download, install and have something running.
By using TomEE, you’re not just saving developing time with a easy to develop and fast environment, but you’re also using a compliant Java EE Web Profile Certified Server thanks to the hard work of TomEE developers.