War-overlay TomEE to deploy your EE application in Tomcat

Regularly we see TomEE users wanting to deploy their app in Tomcat. Most of the time it is because they can’t select the container (company policy, cloud…).

Until now it needed some advanced knowledge, now it is easier :).

I’ll suppose you have a EE war. To deploy it with TomEE 1.7 (coming very soon!) you just need to overlay the tomee webapp you want (tomee-webapp for webprofile, tomee-jaxrs-webapp for jaxrs, tomee-plus-webapp for plus distribution) and add the new module tomee-overlay-runner.

Here my pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">






TomEE webapp(s) web.xml defines metadata-complete to true which would prevent your application to be scanned if you don’t exclude the web.xml (done in previous snippet).

Then just drop the produced war in a Tomcat and you’ll (Tom)EE in a normal Tomcat :).

Basically the overlay is providing in the webapp the needed dependencies (why you have to select the right one depending your need) and the tomee-overlay-runner is a ServletContainerInitializer booting TomEE and deploying your application. It also means you can’t use any EE features before ServletContainerInitializer are called (which should be fine for most of the cases).

No more reason to not use TomEE ;).

2 thoughts on “War-overlay TomEE to deploy your EE application in Tomcat

  1. mauroprogram

    Please do you gave a git repo with a example?
    I have read above that i not can use any EE features before ServlerContainerImitializer is called.
    So i you ask 3 think :
    1 example that not work
    2 if i define a datasource into web-inf/resources.xml of my own web application , it work when i deploy the war at plain tomcat ?

    3 i would use the new tomee1.7 plus for create the war and deploy the generste war into a plain tomcat

    How change the dependencies for tomee overlay runner ? A git repo example ?

    Tank you mauro

    1. rmannibucau Post author


      you can’t use most of EE before ServletContainerInitializer and with this solution during ServletContainerInitializer invocation – this is normal since it defines the startup of your app.

      about resources.xml it is a tomee feature, for tomcat you can use META-INF/context.xml (not WEB-INF/classes/META-INF/context.xml but META-INF/context.xml directly)

      To use tomee 1.7 just use 1.7.0 versions instead of the snapshots


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s