• No results found

Architecture, design and tools for Joly

5.3 Web servers

A J2EE web application is packaged as a WAR file (Web Application aRchive) so it can be deployed to a Java web container and accessed by http clients through the internet. The web container needs to support the JSP and Servlet API versions used in the application. The WAR file will contain all the Servlets and JSPs that make up the web application, as well as any supporting class files and static content such as html files. An XML deployment

descriptor file is used to define how the web container should deploy the web application.

The web application acts as a delegate to the domain logic. The domain logic can either be classes in a specific classes directory of the web application, separate JAR files in a library of the web application, or standalone Enterprise Java Beans (EJBs) separated from the web application. If the domain logic is to be accessed by external components, such as EJBs, the domain logic cannot be a part of the WAR and deployed to a web container, because then the files will not be visible to these external components. For an application with such

requirements, the domain logic needs to be packaged in an EAR file (Enterprise Application aRchive). To deploy an EAR file it is not sufficient with a web container. It requires an additional type of container – an EJB container. To have an application that has both a web module and an EJB module, it requires both containers and thus a full J2EE application server.

For the Joly application it is sufficient to put all the domain logic in the WAR, because the domain logic is not going to be accessed from other components than the Servlets within the web application. In addition, the domain logic does not depend on interaction with any external components such as EJBs, thus we only need a web container to which we can deploy our application.

The DHIS 2 will be a significantly larger system than the Joly application and this could lead to the need of a full J2EE application server to serve different types of clients, not just HTTP clients. In addition, it is likely that the system will be made up of more J2EE components that need another container than a web container to run, and components that need to be able to interact interchangeably with each other. To support such a large-scale J2EE application, an application server that supports the full J2EE stack is required.

For the Joly application we have considered different open source web containers that support our deployment requirements. The requirements are simple and few:

- Support for the Servlet 2.4 API. - Support for the JSP 2.0 API. - Support for the HTTP 1.1 protocol.

There are many open source implementations of the J2EE references for web containers. Sun Microsystems’ own implementation, which is part of the J2EE development package, is not free and open source so we can not use this server in distribution of the Joly application. Because of this restriction we have chosen to omit it all together and use an open source implementation during development as well as for deployment of the application.

5.3.1 Jetty HTTP server and Servlet/JSP container

Jetty is an open source Java web server distributed under the Apache 2.0 License, free for commercial and non-commercial use and distribution. The user and developer community of Jetty is very active and the server has been used and included in many development projects. Because the server is small and easily embeddable into other projects and products, it is often used to provide http and servlet management for larger-scale products. For instance, the Jetty server is being used in open source application servers such as JBoss, Jonas and Apache Geronimo, and it can also be found in IBM and Cisco products.

We have not located any commercial documentation of the Jetty server, a reason for this could be that Jetty is a very simple web container, and there shouldn't be any need for a complete book to cover its functionality. The mail lists indicate that there is an ongoing effort to improve the web container, which is also confirmed by the fact that a new version, Jetty6

beta, is under development. Because of all this we consider Jetty to be a mature and stable web container that can be used for the development of Joly.

Jetty can be considered both as a HTTP server and as a JSP/Servlet container. As a core HTTP server (supporting HTTP 1.1) it can serve static content such as HTLM. As a

JSP/Servlet container it can be used for deployment of standard J2EE web applications. Jetty uses Tomcat’s JSP parsing module, the Jasper JSP engine, for compiling JSPs. This module is included in the Jetty release. Because Jetty supports both HTTP and JSP/Servlets it can be used as a standalone web server.

Jetty has been released with every new JSP and Servlet version, thus Jetty supports our requirement of JSP 2.0 and Servlet 2.4 support, and as mentioned, HTTP 1.1.

5.3.2 Apache Tomcat Servlet/JSP container

Tomcat is an open source Java web server developed by the Apache Software Foundation as one of their top level projects. It is distributed under the Apache 2.0 License, and like the Jetty server, available for both commercial and non-commercial use. Amongst the

contributors to the development of Tomcat is Sun Microsystems. Sun has included the code base of Tomcat in the J2EE SDK application server. Other products embedding Tomcat includes JBoss, Jonas and Geronimo application servers.

Tomcat is often used in combination with the Apache HTTP server to provide static content, but Tomcat also includes an internal HTTP server and can therefore be configured to be used as a standalone web server.

To use Tomcat as a standalone web server one must configure a HTTP Connector component. Because Tomcat is mostly used with Apache HTTP, the documentation for configuring Tomcat most often refer to how to set up Apache as the HTTP server. Our experience with setting up Tomcat leaned us towards the opinion that Tomcat was

unnecessary troublesome to configure. Because Tomcat requires more configuration than the Jetty server, we have chosen to use Jetty. Still we would like to point out that there is no significant difference between these two web servers. It is also unnecessary for both Joly and

DHIS to commit to only one web server. The objective of both developments is to make a portable application, thus being able to run on any Java web server that supports the technical requirements.

Product License Community Activity Documentation Comments Candidate

Jetty Apache

License 2.0 Active community. Last stable version 5.1.10 released 5.01.05

Reference manuals

Mail lists Lightweight container X

Tomcat Apache License 2.0 Active and large community. Last stable version 5.5.17 released 14.04.06 Reference manuals Mail lists Commercial Lightweight container, some extra configuration required X

Figure 5.3.1 Evaluation of web containers after the criteria for evaluating FOSS.

5.3.3 Open source J2EE application servers

Because of an incompatibility between free and open source licenses and Sun Microsystems’ legal agreement that defines how Java standards are to be developed, there has not been an open source implementation of a full J2EE application server. In recent years however, there has been made changes to the Java Community Process so that it now allows free and open source implementations of J2EE specifications.

After the change in the Java Community Process, the Apache Software Foundation became the first open source J2EE TCK (Technical Compatibility Kit) licensee [44]. The ASF started a project called Geronimo for the development of a certified server implementing the full J2EE stack. Other J2EE certified implementations that followed were JOnAS and JBoss. These relatively new open source J2EE implementations can provide a way for DHIS to take advantage of the full J2EE stack, developing a large-scale J2EE application, and still be able to deploy the application on an open source server.