31,19 €
Apache Tomcat (or simply Tomcat) is an open source servlet container developed by the Apache Software Foundation (ASF). The latest major stable release, Apache Tomcat version 7 implements the Servlet 3 and JavaServer Pages 2 specifications from the Java Community Process, and includes many additional features that make it a useful platform for developing and deploying web applications and web services.Apache Tomcat 7 Essentials follows a practical approach to teach installing, configuring, and maintaining Tomcat. It helps you to understand the middle architecture for hosting multiple websites and also provides the confidence to implement middleware support. It imparts to you the capacity to resolve migration issues and also provides regular maintenance solutions. This is the first and only book to cover upgrading to Tomcat 7 from previous versions.The journey of the reader starts at the beginner level and ends at the expert level. The content is designed in such a way that it balances the theory and practical approach for understanding concepts related to handling middle ware and web issues.In this book, you will go through a three-phase life cycle. The first cycle consists of installation, configuration of Tomcat 7 on different OS, and other configurations related to JDBC, port, deployment etc. The second phase deals with the building of enterprise application setup and high availability architecture (clustering load balancing). The third and critical phase will teach you to handle critical issues, performance tuning, and best practices for various environment stacks like dev/QA/stage/production.This book gives you a wider vision of using Tomcat 7 in web technologies and the skill to optimize their performance using Apache Tomcat 7.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 257
Veröffentlichungsjahr: 2012
Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: March 2012
Production Reference: 1160312
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK..
ISBN 978-1-84951-662-4
www.packtpub.com
Cover Image by Vinayak Chittar ( <[email protected]> )
Author
Tanuj Khare
Reviewers
Zeeshan Chawdhary
Ty Lim
Vidyasagar N V
Acquisition Editor
Usha Iyer
Lead Technical Editor
Susmita Panda
Technical Editor
Unnati Shah
Copy Editor
Laxmi Subramanian
Project Coordinator
Vishal Bodwani
Proofreader
Linda Morris
Indexer
Rekha Nair
Graphics
Valentina D'Silva
Manu Joseph
Production Coordinator
Alwin Roy
Cover Work
Alwin Roy
Tanuj Khare has been a professional in IT for over six years. He is involved in process improvements using the ITIL framework and techniques such as Lean Six Sigma. He is MCSA and ITIL certified, and has expertise in handling critical production server issues. He also has a track record of dealing with many complex problems. His quick resolution to issues faced in the production environment has helped his team and clients in a big way.
Tanuj has Subject Matter Expertise (SME) in Tomcat, WebLogic, and JBoss server administration. His experience includes working with large-enterprise web hosting environments for J2EE containers with small teams, and his quick turnaround time gave on-time delivery. Apart from this, his technical expertise in Root Cause Analysis, Problem Management, Migration of enterprise applications, and upgrade of web application servers are commendable. Up to now, he has migrated more than 100 enterprise applications and upgraded J2EE web applications. He has also managed environments with over 1000 middleware instances.
Apart from work life, Tanuj enjoys playing Table Tennis and exploring new technologies. He is a good dancer. This is his first book.
I would like to express my gratitude to all the people who have helped me to make this book better. I thank Ranveer Chandel, who has helped me to provide high technical standards for this book.
I would like to thank Archana Kannoujia, who has patiently helped me to improve my writing style.
I would like to thank Mitesh Parikh and Giri Moturi for their support.
I would like to thank Usha Iyer, Vishal Bodwani, Susmita Panda, and everyone else at Packt Publishing for all their hard work to get this book published. A special thanks to Unnati Shah for her hard work and dedication to get this book published.
I would like to thank Ty Lim,Vidyasagar N V, and Zeeshan Chawdhury for providing their valuable guidance and support that helped me achieve the high technical standards.
And finally, I'd like to thank all my colleagues and friends, with whom I've worked throughout my career, for contributing to my professional development.
Zeeshan Chawdhary is the CTO of Wcities Inc., a location-based travel content provider, running technical operations from their Technical Headquarters in Mumbai.
He is a do-it-all and code-in-any-language guy, having worked with various technologies from 3D gaming to consumer websites, from iPhone apps to serving over 30 million hits over the Cloud.
He is currently writing two real-world-use books with Packt Publishing which are, iPhone Location Aware Applications by Example - Beginners Guide and Windows Phone 7.5 - Building Location Aware Applications.
He can be reached at imzeeshan on Twitter. He currently blogs at http://justgeeks.in.
I would like to thank the great people at Packt for letting me review this book. Special thanks to Vishal Bodwani, Susmita Panda, Leena Purkait, Amey Kanse, Alina Lewis, and a special mention for Mary Nadar, for having introduced me to the Packt family.
Ty Lim has been in the IT industry for over 15 years. He has worked for several startup companies in the mid 1990s and found himself working at several major corporations after his stint in Silicon Valley. He has worked in the following industries: Software Development, Consulting, Healthcare, Telecommunications, and Finance. He has experience in utilizing JBoss, Tomcat, and WebSphere middleware technologies. He holds a Bachelor of Science degree in Computer Science from the University of the Pacific, and is currently pursuing a Master of Science degree in CIS from Boston University.
He has also worked on IBM WebSphere Application Server v7.0 Security, Packt Publishing.
I would like to thank all my friends and family for their continued support. I am truly blessed to have such great support. It is because of all of you that I consider myself a very happy man.
Vidyasagar N V was interested in Computer Science since his early age. Some of his serious work in computers and computer networks began during his high school days. Later, he went to the prestigious institute of technology, Banaras Hindu University for his B.Tech. He has been working as a Software Developer, Data Expert, developing and building scalable systems since then. He has worked with a variety of 2nd, 3rd, and 4th generation languages. He has also worked with Flat files, Indexed files, Hierarchical databases, Network databases, Relational databases, NoSQL databases, Hadoop, and related technologies.
Currently, he is working as a Senior Developer at Ziva Software Pvt. Ltd, developing a big data-based structured data extraction technique from the Web and local information. He enjoys producing high-quality software, web-based solutions, and designing secure and scalable data systems.
He has also worked on PHP and MongoDB Web Development Beginner's Guide, Packt Publishing.
He can be reached at <[email protected]>.
I thank the almighty for giving me such a blessed life and thank my parents, Mr. N. Srinivasa Rao and Mrs. Latha Rao, and my family who supported and backed me throughout my life. I thank my friends and all those people who donated their time, effort, and expertise by participating in open source software projects. Also, thanks to Packt Publishing for selecting me as one of the technical reviewers for this wonderful book. It is my honor to be a part of this book.
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
I would like to dedicate this book to my mom, Mrs. Shashi Khare and dad, Mr. Rajkumar Khare, for standing beside me during the writing of this book.
Without their support and encouragement, completing this book would have been a much more difficult task.
This book will help you resolve these issues and boost your confidence in handling Apache Tomcat 7 administration using the tips, tricks, and best practices used by various industry experts to maintain their middleware infrastructure. The best thing that the author did while designing the content is a practical solution, with a detailed description of why we are doing this solution.
Apache Tomcat (or Jakarta Tomcat, or simply Tomcat) is an open source servlet container developed by The Apache Software Foundation. The latest major stable release, Apache Tomcat version 7, implements the Servlet 3 and JavaServer Pages 2 specifications from the Java Community Process. It includes many additional features that make it a useful platform for developing and deploying web applications and web services.
Apache Tomcat 7 Essentials follows a practical approach to explain installing, configuring, and maintaining Tomcat. It helps you to understand the middleware architecture to host multiple websites and also provides the confidence to implement middleware support. It imparts to you the capacity to resolve migration issues and also provides regular maintenance solutions. This is the first, and only, book to cover upgrading to Tomcat 7 from the previous versions.
The journey of the reader starts at the beginner's level and ends at the expert level. The content is designed in such a way that it balances the theory and practical approach for understanding concepts related to handling middleware and web issues.
In this book, you will go through a three-phase life cycle. The first cycle consists of the installation, configuration of Tomcat 7 on different OSes, other configurations related to the JDBC, port, deployment, and so on.
The second phase deals with the building of an enterprise application setup and high availability architectures (clustering and load balancing). The third and critical phase will teach you to handle critical issues, performance tuning, and the best practices for various environments such as Dev/QA/Stage/Production.
This book gives you a wider vision of using Tomcat 7 in web technologies and the skill to optimize its performance using Apache Tomcat 7.
Chapter 1, Installation of Tomcat, covers the Apache Tomcat history and the new features introduced in Tomcat 7. The step-by-step installation of Tomcat 7 on Windows and Linux operating systems and common problems that may arise during the installation and their possible solutions are also discussed.
Chapter 2, Configuration and Deployment, covers the configuration of Tomcat including the DataSource configuration for different databases such as Oracle, MySQL, and PostgreSQL, and Context Path creation using an application. Various ways to perform deployment including deployment using Tomcat Manager for a sample application and troubleshooting common issues are also discussed.
Chapter 3, Performance Tuning, explains the different ways of performance improvement and techniques in Apache Tomcat 7. Step-by-step configurations for Connectors, JVM performance tuning, and OS parameter optimization are also covered.
Chapter 4, Integration of Tomcat with the Apache Web Server, explains the integration of Apache/IIS with Tomcat 7, integration of various components such as mod_jk, mod_proxy, and real-time issues which may arise during integration, along with their solutions.
Chapter 5, Securing Tomcat 7, explains the various policies of Tomcat 7 and its functionalities such as the Catalina policy and System level policy. Measures to enable security and their benefits such as SSL, best practices used in real-time industries to secure Tomcat 7 in the production environment, by doing the configuration change and SSL implementation are also covered.
Chapter 6, Logging in Tomcat 7, explains the different methods of enabling logs in Tomcat 7—log4j and JULI. Also, the best practices used for log analysis, tips, and tricks are discussed.
Chapter 7, Troubleshooting in Tomcat, covers different issues faced by the application/web administrators in a real-time environment, how to avoid these issues in the production environment using different techniques with errors and their solutions, thread dump analysis and tools used for thread dump analysis, memory issues, steps for troubleshooting real-time problems, and web server benchmarking.
Chapter 8, Monitoring and Management of Tomcat 7, explains various processes of monitoring in Tomcat 7, components using Tomcat Manager and JConsole, such as different ways of monitoring, how monitoring is done in Tomcat 7, JConsole, and how it is used.
Chapter 9, Clustering in Tomcat 7, explains clustering of Tomcat 7 and its implementation technique. Topics included are clustering architecture, horizontal and vertical clusters and their benefits, implementation of horizontal and vertical clustering on Tomcat 7, and verification of clusters.
Chapter 10, Tomcat Upgrade, explains various strategies used in the upgrade from Tomcat 6 to Tomcat 7 and the various steps followed during the upgrade process such as the life cycle of the upgrade, upgrade configuration of Tomcat 7, DataSource configuration, and discussions on various ITIL processes used during upgrade.
Chapter 11, Advanced Configuration for Apache Tomcat 7, explains the advanced configuration of Tomcat 7 and its optimization parameters. Key points covered in the environment are virtual hosting, features of Development/QA/Stage/Production, Tomcat as a service, and running Tomcat as a non privileged user.
To understand the contents of this book, you should have a basic knowledge of Windows or Linux operating systems and it is an added advantage if you have some knowledge in Java.
If you are a J2EE Administrator, Migration Administrator, Technical Architect, or Project Manager for a web hosting domain, and are interested in Apache Tomcat 7, then this book is for you. If you are responsible for the installation, configuration, and management of Tomcat 7, then this book will be of help to you too.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "Due to Tomcat 7's support for web fragments, developers now don't need to implement the specific library configurations for their application web.xml."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "The previous screenshot shows the packages which are available in md5, and by clicking on md5 on the website, we can compare the checksum generated in our system with the value given on the site."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title through the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
Apache Tomcat is an open source Java-based web and servlet container, which is used to host Java-based applications. It was first developed for Jakarta Tomcat. Due to an increase in demand, it was later hosted as a separate project called Apache Tomcat, which is supported by The Apache Software Foundation. It was initially developed by James Duncan Davidson, a software architect at Sun Microsystems. He later helped make this project open source and played a key role in donating this project from Sun Microsystems to The Apache Software Foundation. Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a "pure Java" HTTP web server environment for Java code to run.
Apache Tomcat version 7.0 implements the Servlet 3.0 and Java Server Pages 2.2 specifications from the Java Community Process. It includes many additional features that makes it a useful platform for developing and deploying web applications and web services.
In this chapter, we will discuss the following topics:
Tomcat was first introduced to the open source group in 1999 and its first version was released with 3.0.x version. Since then, it has been greatly supported by the open source community and widely accepted in the IT industry. In the current scenario, Tomcat is running in production environments, as well as being used for mission-critical projects in various industries. The following mentioned details give us a quick history of the versions.
Over the 12 years of of its successful journey, Tomcat has reached various states and given the IT industry various releases. Tomcat road maps outlined with their stable releases are mentioned as follows:
Version
Release Date
Description
3.0.x. (initial release)
1999
Merger of donated Sun Java Web Server code and ASF, and implements Servlet 2.2 and JSP 1.1 specifications.
3.3.2
March 9, 2004
Latest 3.x release.
4.1.40
June 25, 2009
Latest 4.x release.
5.5.32
February 1, 2011
Latest 5.x release.
6.0.32
February 3, 2011
Latest 6.x release.
7.0.0 beta
June 29, 2010
First Apache Tomcat release to support Servlet 3.0, JSP 2.2, and EL 2.2 specifications.
7.0.11
March 11, 2011
Fourth stable version.
7.0.12
April 6, 2011
Current stable version.
For more information on version changes, release, and comparison, visit http://en.wikipedia.org/wiki/Apache_Tomcat and http://wiki.apache.org/tomcat/FrontPage.
Apache Tomcat can be classified based on different components, such as the JDK version, enhancement, stability, and so on. Let's take a real time example, where you want to take a decision on which Apache Tomcat version to deploy for an application. For example, if an application is using Servlet 2.4 and JSP 2.0, then we should always go for the 5.x version. In reality, it's a difficult job to find out which version of Tomcat we should use to utilize the system resource properly.
Normally, these tasks would be done by the company's technical architect, and they are solely responsible for the technical specifications used in any product. Based on the features of Tomcat, let us quickly go through the comparison of Tomcat with different versions:
Features
7.x
6.x
5.x
4.x
3.x
Version specifications
Servlet 3.0, JSP 2.2, EL 2.2
Servlet 2.5, JSP 2.1
Servlet 2.4, JSP 2.0
Servlet 2.3, JSP 1.2
Servlet 2.2, JSP 1.1
Stable:
Yes
Yes
Yes
Yes
Yes
Enhancements
Yes
Yes
Unlikely
Highly unlikely
Highly unlikely
Bug Fixes
Yes
Yes
Yes
Highly unlikely
Highly unlikely
Security Fixes
Yes
Yes
Yes
Highly unlikely
Highly unlikely
Releases
Yes
Yes
Yes
Highly unlikely
Highly unlikely
Release Manager
Mark Thomas (markt)
Jean-Frederic Clere (jfclere)
Filip Hanik (fhanik)
Mark Thomas (markt)
Bill Barker (billbarker)
Process
CTR
RTC
RTC
CTR
CTR
Listed on download pages
Yes
Yes
Yes
No
No
JDK version
1.6
1.5
1.4
1.3
1.1
In the previous table, highly unlikely means that the user using the previous version necessarily needs to have the upgraded higher version to support the new improved features. It also involves security fixes for the current version.
In the previous section, we discussed the various support matrices for Tomcat versions, we are now aware of the support specifications (JDK support, EJB, and Servlet) for Tomcat. Let's try to understand, and quickly review the new features/enhancements for Tomcat 7.
Apache Tomcat 7.x was released with some key improvements over Tomcat 6.x and real time implementation of Servlet 3.0, JSP 2.2, and EL 2.2 specifications. Apart from these, it also solves some major issues from previous releases.
Tomcat had a chronological problem of memory leaks in 4.x/5.x versions. While reloading the applications in the entire life cycle of Tomcat, OutOfMemoryError exceptions were generated. Tomcat has put an exceptional effort in tracking down the bugs and issues related to memory, in order to avoid memory leaks.
Tomcat 7 offers great support for Servlet 3.0. Servlet 3.0 helps developers to code very easily and also provides significant support for asynchronous programming techniques. The types of support provided are:
Tomcat 7 includes two new features for logging, in order to provide a good understanding to the users for log analysis:
