How to deploy web project on tomcat?
By Ali Hammad Baig on 10:55 PM
Filed Under: deploying web application on tomcat, Tomcat
There are two methods to deploy an application in tomcat
1- Deploy the application in webapps directory directly under tomcat directory.
Put the .war file of project in webapp directory and restart tomcat.
2- You have a working project with correct directory structure anywhere on filesystem and you want to deploy that without moving it to webapps directory.
But I don’t wanna create a war file then putting it in webapps directory and later on whenever I make a change I’ll have to deploy it again.
To overcome this issue do the following
2.1- Go to tomcat directory
2.2- Then go to tomcat_home/conf/Catalina/localhost directory
Note: sometimes Catalina/localhost directory structure does not exit. If this is case then first create Catalina direcoty and then inside Catalina create localhost directorie.
2.3- Create an xml file. Give it a name. This name will be used to access the application from URL. In my case I name it adbank.xml and in the URL for my application is
http://localhost:8080/adbank
2.4- Add the following line in this xml file
path: provide any name(I personally don’t know its functionality but the path did not matte for me)
docBase: provide the path to you project. I had a few problems with it, I solved it when I provided the path up to the directory where my project’s WEB-INF directory is placed.
2.4- Restart tomcat
2.5- Access you application with a URL similar to this one
http://localhost:8080/adbank
replace adbank with the name of your xml file.
More information
http://www.cs.ucl.ac.uk/teaching/java/tomcatfaq.html
Set up Tomcat web server in Linux
By Ali Hammad Baig on 4:13 AM
Filed Under: Linux, Tomcat, tomcat environment variables, tomcat on linux, tomcat on ubuntu, tomcat tutorial, Ubuntu
To setup Apache Tomcat in Linux do the following
1- Download Tomcat latest version from here
http://tomcat.apache.org/download-60.cgi
On the left panel under 'Download' heading, click on your required tomcat version.
select tar.gz (pgp, md5) under 'Core' and 'Binary Distribution' headings.
2- Extract tar at an appropriate place. For example /home/tomcat_home
3- Set Tomcat environment variables
In windows
Right click My Computer> Properties > Advance >Environment Variables > under User variables > New and set CATALINA_HOME to the java home directory.
In Linux
Go to /home/your_home_directory then show the hidden files (View/ Show Hidden Files). Find and open .bashrc file.
Go to the end of the file and insert the following lines.export CATALINA_HOME=/home/tomcat_home/export PATH=$PATH:/home/tomcat_home/bin
4- Keep in mind that your JAVA_HOME environment variable must also be set.
You can check whether JAVA_HOME is set or not, type following in terminaljava -version
If it does not return the java version then your JAVA_HOME is not set.
To set JAVA_HOME, insert the following lines ( java installation paths may vary on your machine)export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.16export PATH=$PATH:/usr/lib/jvm/java-1.5.0-sun-1.5.0.16/bin
4- Open Terminal and typestartup.sh
press Enter and you tomcat is now running :)
Related Topics
You may not see tomcat console out in Linux like the way you see in windows. To do so view the following tutorial
How to view Tomcat output on console in Linux
~*~ Technology is good ~*~