Ashutosh has posted 1 posts at DZone. View Full User Profile

Tomcat - Is This an Application Server ?

06.09.2008
| 43431 views |
  • submit to reddit

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)
  • JavaMail
  • 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 :

JMS in J2EE Architecture

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.

EIS in J2EE Architecture

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.

Webservices, EJBs, Multiple WAR in J2EE Architecture

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 !!

Java Tutorials by Ashutosh Sharma, please visit :http://sharma.ashutosh84.googlepages.com/
Check out blog entries at
http://javaforweb.wordpress.com/

Published at DZone with permission of its author, Ashutosh Sharma.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Dimitris Menounos replied on Mon, 2008/06/09 - 9:53am

 Is Tomcat an Application Server? If we take the wikipedia definition then certainly yes.

An application server is a software engine that delivers applications to client computers or devices, typically through the Internet and using the HyperText Transfer Protocol. Application servers are distinguished from web servers by the extensive use of server-side dynamic content and frequent integration with database engines.

 Although we might take a different answer if we ask the same question to a Java EE vendor.

 Personally I agree more with wikipedia. Any program or library that makes applications available over the network is an application server runtme. Tomcat can make an application available either directly via programming servlets or indirectly by using web services, spring or other frameworks that expose generic services through the HTTP protocol.

Are JNDI, JMS, JTA and all the other Java EE features usefull? Yes. Do they define the term "Application Server"? No.

Steven Baker replied on Mon, 2008/06/09 - 10:05pm

my thoughts exactly Dimitris!

Lokeshwaran Dev... replied on Tue, 2008/06/10 - 1:16am

[quote]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[/quote]

Tomcat is not just a web server, its mainly a web container (implemetation of java servlet and JSP specifications).

Tomcat might just match the definition given for Application Server in wikipedia, but if you look at the list of java application servers, Tomcat is not one among them. I think it would be appropriate to call them 'Enterprise Applications Servers' so that Tomcat can be called an 'Application Server'.

Its a good explanation about the differences between a simple servlet container and a full-fledged application server.

Sangeetha Veera... replied on Wed, 2010/05/19 - 5:03am

Very good article which explains the difference between web and application server.

Akshay Ahuja replied on Mon, 2010/08/16 - 3:03am

Very Important Info, and given in very concise and articulate manner. Thanx a lot

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.