Search code examples
tomcatjakarta-eejbossglassfishjava-ee-6

Java EE scenarios that cannot be handled by Tomcat


Tomcat only implements the web container of the Java Enterprise Edition architecture. In contrast, e.g. GlassFish implements a full Java EE stack. This has been discussed a lot on stackoverflow.

However, for a Java EE beginner like me it is hard to imagine what cannot be done with Tomcat. Could you please give some short examples?


Solution

  • From the Apache tomcat documentation:

    Is tomcat an EJB server? Can I use EJBs with tomcat?

    Tomcat is not an EJB server. Tomcat is not a full J2EE server. Tomcat is a Servlet container. Tomcat does support those parts of the J2EE specification that are required for Servlets, such as a subset of JNDI functionality. Furthermore, you can connect to remote J2EE servers, or run tomcat embedded inside a full J2EE server.

    Some of the differences this implies is...

    • Tomcat can only handle WARs, not EARs
    • Tomcat does not support any types of EJBs (like Session Beans, MDBs, Timers, etc.)
    • Tomcat has no JPA support
    • Tomcat has limited JNDI functionality (not sure of the details here)

    Tomcat can be used inside of an J2EE conatiner to use as the web conatiner.

    Tomcat is much lighter-weight regarding resources and file system foot prints.

    If you need J2EE functionality, my suggestion would be to bite the bullet and use Glassfish despite the complexity and resource requirements (compared to tomcat, Glassfish is quite easy to use compared to others like Weblogic, and JBoss). If not, stick with tomcat, it will keep things simple and fast for you. Either way, it isn't hard to switch your project packaging later and swap out containers.