Artikel Terbaru

Saturday, 28 January 2012

How to setup and install tomcat 7 server in windows?

Tomcat is application server which supports for running java,j2ee based applications.

Tomcat provides different services like any other applicaiton servers such as jboss, websphere

Is tomcat Application Server or Webserver?

Yes. Tomcat is a application server which provides the following services

1.Object Management like automatic object creation,modifying, and garbage collection
2.JDBC Connection pool mechanism
3.Maintaining multiple nodes in cluster setup
4.99.99 starnd up time for running applicaitons
5.Configuring the different j2ee services like mbeans, enterprise objects like message beans with in admistrative tools
6.Integration with different security frameworks like CUP with LDAP, and database realms

The advantages of the above services are that developer need not to write this and can concentrate on his business logic.

Web server is server which serves plain request annd gives the response. apache webserver need not be talk to database

But in produciton scenario,apache httpd server acts front controller which delegates the request to applicaiton server, the applicaton server talks to database and do the busines logic and send the response to webserver, finally webserver send the response to client.

Setup apache Tomcat 7.0 in windows:-

following are the sequence of steps to setup tomcat in windows.

JDK settigns for tomcat

For tomcat, jdk is required, make sure install jdk 1.6 version and configure the following environment variable
JAVA_HOME=D:\jdk path

download tomcat 7.0.25

Before downloading tomcat 7.0 to your machine, we need to find out 32 bit or 64 bit machine you are going to install, check here to find out 32 bit or 64 bit for your machine.

First try to download the download Tomcat 7.0 server from file is downloaded to your machine, extract or unzip using winrar or zip tools to your drive(d:\)

let us say i have extracted to G drive like G:\apache-tomcat-7.0.25

tomcat server folder structure

Coming to the folder structure as follows

\bin folder :-bin folder contains scripts for setting classpaths,starting and running scripts. scripts with .bat extensions are for windows server and .sh for linux box.
setclasspath.bat is used to configure the any classpath related settings like JAVA_HOME etc.
startup.bat is to start the tomcat as non servce mode meaning if we don't install tomcat as windows service, this will increase performance for tomcat
tomcat7.exe is to start the tomcat as window servce meaning if we install tomcat as windows service
shutdown.bat is to stop or shutdown the tomcat server.
catalina.bat is to set the tomcat environment related settings like jvm options, heap size settings and garbage collector settings

\conf folder:- configuration related files in tomcat like port number and log level changes etc..
server.xml contains settings for tomcat container like listening port number and resouce configuration like jdbc datasource, security settings
tomcat-users.xml contains authentication and authorization details for tomcat administration console tool

\lib folder:-
Lib folder contains all the jars required to run for tomcat. This bootstrap class loader for tomcat meaning, jars in this folder are loaded into the container when tomcat application is started. This jars are avilable to all the applications deployed to tomcat container. we can overirde the jars with in application.
always avoid duplicate with different version of jars in lib folder with your application folder. otherwise you will be in trouble with a lot of NoClassDefFounder issues.

\logs folder :- contains all the tomcat server related logs like standard out logs, access logs, and catalina logs.if we have any issues in tomcat, This folder is first chock to look for the detailed information about the error.

\temp and work folder:- contains the temporary tomcat work folder for your tomcat. It will acts cache for your application.

\webapps folder:- This is main folder where all your applications are deployed to. if you wan to deploy your application, copy your webapplication war file to this location.

That's about the folder structure.

tomcat environment settings

make the following environment settings for your tomcat.


Starting tomcat server

start the tomcat server using startup.bat. this opens the console starts the tomcat serer

Stopping tomcat server

stopping or shutdown the tomcat server using shutdown.bat. this opens the console stops the tomcat serer

finally you have completed the tomcat setup in windows and got some basic idea on tomcat server.

Please feel free to comment if you have any questions.