Tomcat in the enterprise

Learn where Tomcat fits, and doesn't, in your enterprise application stack

When Java developers start talking about application servers, Tomcat is often thrown into the mix. After all, it's one of the most popular options for lightweight development scenarios, and in many cases meets the need for an application server, even though it is technically a Web server. In this article Jeff Hanson engages the question of whether Tomcat is an app server, first by explaining what differentiates application servers, Web servers, and Java EE containers, and then by evaluating Tomcat's suitability to a variety of common Java enterprise development scenarios.

Confusion over whether Tomcat is an application server tends to result in heated discussion among Java developers -- some claiming it absolutely is and some that it definitely is not. In truth, Tomcat often is used as an app server, and for some scenarios it is perfectly suited to that role. For developers using Tomcat as an app server, it makes sense to classify it as such, regardless of formal definition.

TomEE and Tomcat

Apache TomEE builds up Tomcat with new features from Java EE 6. Read an interview with TomEE project lead David Blevins, then get a hands-on introduction to TomEE on JavaWorld. Want more enterprise Java news and tutorials? Get the Enterprise Java newsletter delivered to your inbox.

In this article I tackle the question of whether Tomcat is an application server. I start by explaining the distinctions between app servers, Web servers, and Java EE containers, and then look at some scenarios where a Web server like Tomcat could be used appropriately as an app server. I show a scaled architecture, starting with the sort of lightweight implementation where Tomcat shines, and concluding with a complex service-oriented architecture, where you would be better off with a full-fledged Java EE application server.

Java EE as a point of reference

Java Platform, Enterprise Edition, or Java EE, is the de facto standard for developing server-side Java applications. As such it is the foundation on which all other server-side Java technologies, including app servers, must rest. Java EE compliance is an essential factor when evaluating the difference between Web servers and application servers.

Java EE extends Java Platform, Standard Edition (Java SE) to support Web services, an enterprise component model, management APIs, and communication protocols for designing and implementing service-oriented architectures, distributed applications, and Web applications. (Note that Web applications are only one sector that Java EE seeks to support.)

A compliant Java EE application server must support features such as an Enterprise JavaBeans (EJB) server and container; JNDI capabilities; a Java Message Service (JMS) framework; a Java Transaction API (JTA) framework; and J2EE Connector Architecture. Java EE servers usually support a hierarchical classloader architecture enabling such functionality as EJB loading/reloading, WAR loading/reloading, manifest-specified utilities, and so on.

Java EE defines containers for client applications, servlets, and EJB components. These containers provide structure and functionality that facilitate the deployment, persistence, and execution of supported components.

Java EE also defines a standard architecture for connecting Java EE applications and application servers to heterogeneous Enterprise Information Systems, such as ERP systems, mainframes, database systems, and non-Java legacy applications. The J2EE Connector Architecture enables a provider of an enterprise system to expose the system using a standard interface known as a resource adapter. The resource adapter allows an application server or enterprise application to use the same interface for different enterprise system vendors. Resource adapters operate within the address space of a host application server.

Figure 1 shows the tiers and components of a typical Java EE application architecture.

Illustration of a typical Java EE application architecture.
Figure 1. A typical Java EE application architecture (click to enlarge)

A Java EE application server is needed to support some, but not all, of the components shown in Figure 1. Using a Java EE server gives you the convenience of hosting a system in a pre-tested environment that offers all of the Java enterprise development services. In some cases, however, the Java EE server brings unnecessary overhead to an execution environment that only requires one or two of these services.

For instance, many Java-based Web applications are deployed to environments that only support the technologies found in a Web server/container, such as servlets, JSPs, and JDBC. In these scenarios you might choose to construct a system piecemeal, using sundry frameworks and providers. Some developers would choose to use Tomcat in place of the Java EE application server given these environmental constraints.

Oftentimes the decision of whether to use an application server or Web server depends on the type of communication needed between application components, so let's consider those options next.

1 2 3 4 Page 1
Page 1 of 4
How to choose a low-code development platform