How to deploy a war file in Tomcat 7
Solution 1
You can access your application from: http://localhost:8080/sample
Deploying or redeploying of war files is automatic by default - after copying/overwriting the file sample.war
, check your webapps
folder for an extracted folder sample
.
If it doesn't open properly, check the log files (e.g. tomcat/logs/catalina.out) for problems with deployment.
Solution 2
step-1. here I'm deploying pos.war First go to tomcat webapps folder and paste it
step-2. go to tomcat->bin folder start tomcat by clicking startup.bat
step-3. go to browser write localhost:port/project name eg. localhost:8080/pos (here my tomcat run on port 8080)
Done....
Solution 3
You just need to put your war file in webapps and then start your server.
it will get deployed.
otherwise you can also use tomcat manager a webfront to upload & deploy your war remotely.
Solution 4
Manual steps - Windows
Copy the .war file (E.g.: prj.war) to
%CATALINA_HOME%\webapps
( E.g.: C:\tomcat\webapps )Run
%CATALINA_HOME%\bin\startup.bat
Your .war file will be extracted automatically to a folder that has the same name (without extension) (E.g.: prj)
Go to
%CATALINA_HOME%\conf\server.xml
and take the port for the HTTP protocol.<Connector port="8080" ... />
. The default value is 8080.-
Access the following URL:
[<protocol>://]localhost:<port>/folder/resourceName
(E.g.:
localhost:8080/folder/resourceName
)
Don't try to access the URL without the resourceName
because it won't work if there is no file like index.html
, or if there is no url pattern like "/
" or "/*
" in web.xml.
The available main paths are here: [<protocol>://]localhost:<port>/manager/html
(E.g.: http://localhost:8080/manager/html
) and they have true
on the "Running" column.
Using the UI manager:
-
Go to
[<protocol>://]localhost:<port>/manager/html/
(usuallylocalhost:8080/manager/html/
)This is also achievable from
[<protocol>://]localhost:<port>
> Manager App)If you get:
403 Access Denied
go to
%CATALINA_HOME%\conf\tomcat-users.xml
and check that you have enabled a line like this:<user username="tomcat" password="tomcat" roles="tomcat,role1,manager-gui"/>
-
In the Deploy section, WAR file to deploy subsection, click on Browse....
Select the .war file (E.g.: prj.war) > click on Deploy.
- In the Applications section, you can see the name of your project (E.g.: prj).
Solution 5
In addition to the ways already mentioned (dropping the war-file directly into the webapps-directory), if you have the Tomcat Manager -application installed, you can deploy war-files via browser too. To get to the manager, browse to the root of the server (in your case, localhost:8080), select "Tomcat Manager" (at this point, you need to know username and password for a Tomcat-user with "manager"-role, the users are defined in tomcat-users.xml in the conf-directory of the tomcat-installation). From the opening page, scroll downwards until you see the "Deploy"-part of the page, where you can click "browse" to select a WAR file to deploy from your local machine. After you've selected the file, click deploy. After a while the manager should inform you that the application has been deployed (and if everything went well, started).
Here's a longer how-to and other instructions from the Tomcat 7 documentation pages.
Admin
Updated on August 20, 2021Comments
-
Admin almost 3 years
I have copied the
sample.war
file into thewebapps
directory of Tomcat, and I can accesslocalhost:8080
.Now how will Tomcat deploy it, I mean do I need to open it in browser? How can I access the application?
-
Mamey almost 13 yearsThe
manager
role in Tomcat 7 is nowmanager-gui
. I got bitten by this one. -
Kevin Meredith almost 12 yearswhat if the WAR is named "ROOT.war?" Where can I find that WAR?
-
xverges over 11 yearsDropping the .war file in webapps hasn't worked for me, and there was no sign of error in the logs. Doing it from the Tomcat Manager did the trick. Not a clue about why the first method failed
-
Koray Tugay over 11 yearsWhat if I want to deploy my sample.war to localhost:8080/somethingdifferent ?
-
Bozho over 11 yearsyou can specify that in META-INF/context.xml
-
Koray Tugay over 10 yearsThe META-INF/context.xml, is it the one in tomcat\conf\context.xml ? Or should it be in my application I am deploying?
-
Bozho over 10 yearsit can be in both places. I prefer it to be within the application
-
Dr.jacky about 9 yearsUnfortunately it doesn't work! Would you like to test my specific war file?! Please download "linshare-core-1.8.4-without-SSO.war" from "forge.linshare.org/projects/linshare/files"
-
Dr.jacky about 9 years@Bozho Unfortunately it doesn't work! Would you like to test my specific war file?! Please download "linshare-core-1.8.4-without-SSO.war" from "forge.linshare.org/projects/linshare/files".
-
jmj about 9 years@Mr.H tail the log when you start the server after placing war, you will find why it is not working
-
haltunbay over 8 years"If the Host autoDeploy attribute is "true", the Host will attempt to deploy and update web applications dynamically, as needed, for example if a new .WAR is dropped into the appBase. For this to work, the Host needs to have background processing enabled which is the default configuration. "
-
user250343 over 8 yearsThis is not a valid undeployment / deployment procedure as it interferes with files exclusively managed by Tomcat. The best reference is Tomcat Web Application Deployment
-
user250343 over 8 yearsWhile this may work in exceptional cases, it is not a valid undeployment / deployment procedure. mysite.www will create a new context if autodeploy="true" and deleting mysite.war deletes the mysite context under several normal conditions. The best reference is Tomcat Web Application Deployment.
-
derwiwie almost 8 yearsIn Ubuntu 14.04.3 the webapps directory is located at /var/lib/tomcat7/webapps .
-
Anthony De Souza over 6 yearsThank you! Additionally, I needed to set permissions to my newly installed Tomcat directory structure so that my WAR could be extracted and log files could be generated.