Tomcat - Is This an Application Server ?
Join the DZone community and get the full member experience.Join For Free
in this post i’ll discuss about apache tomcat web server and look in to its extent for support in j2ee environment.
apache tomcat is 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.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.
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. the j2ee connector architecture enables a provider of an enterprise system to expose the system using a standard interface known as a resource adapter.
using a java ee server(application 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.
web applications vs. enterprise applications
for some, the confusion over tomcat’s definition points to the deeper question of what differentiates an enterprise application from a web application. traditionally, a java enterprise application is defined as a combination of the following components and technologies:
- ear files
- java servlets
- javaserver pages or javaserver faces
- enterprise javabeans (ejb)
- java authentication and authorization service (jaas)
- j2ee connector architecture
- javabeans activation framework (jaf)
- java message service (jms)
- java persistence api (jpa)
- java transaction api (jta)
- the java management extensions (jmx) api
- java api for xml processing (jaxp)
- the java api for xml-based rpc (jax-rpc)
- the java architecture for xml binding (jaxb)
- the soap with attachments api for java (saaj)
- java database connectivity (jdbc) framework
a java web application, meanwhile, is said to combine a subset of java enterprise application components and technologies, namely:
- war files
- java servlets
- javaserver faces or javaserver pages
- java database connectivity (jdbc) framework
in a typical java ee web application, an html client posts a request to a server where the request is handled by the web container of the application server. the web container invokes the servlet that is configured to handle the specific context of the request.
once the servlet has received the initial request, some form of request dispatching ensues in order to perform the necessary business logic for completing the request. one or more business services or components are then invoked to perform business logic.
most business services or components require access to some form of data storage or information system. oftentimes an abstraction layer between the business service and the data store is provided in order to protect against future changes in the data store. daos (data access objects) are often employed as data abstraction components in this situation.
when the dao invocation step is complete, the response data is passed back up the chain of command, usually as one or more java beans. the java beans are then passed to some type of state machine and/or view manager in order to organize and format the markup response. when processing is complete for a given request, a formatted response is passed back to the html client.
now, suppose we add a requirement to the application for asynchronous messaging between business service components. in a java-based system, this would typically be handled using the java message service (jms) as shown in figure :
most web servers do not offer jms as a standard feature, but it is simple enough to add a jms implementation to a web server environment.
the application scenario depicted in figure above could be handled quite easily with just a web server providing a servlet engine and jsp engine.
now we add the requirement for connectivity between business services and disparate enterprise information systems. java ee offers the java connector architecture as a common standard to meet this challenge.
the architecture is now approaching a complexity that is arguably better suited for a java ee application server.
a web server such as tomcat could possibly be used in combination with other frameworks to meet the requirements, but system management and monitoring complications might make the server/framework mix impractical.
figure presents a moderately complex, java-based, service-oriented architecture employing all of the technologies along with communication between multiple war deployments, ejbs, and web services.
the architecture in figure above has entered the realm of complexity that requires a tested, scalable, manageable java ee enterprise application server. once again, a development team with the proper skill level could use tomcat for the web tier and piece together technologies and frameworks to support the business and data tiers.
what i personally feel is to support this type of architecture using web server is impractical. but most of the tasks that are involved in j2ee environment can be supported by apache tomcat web server !!
Opinions expressed by DZone contributors are their own.