How to deploy a Java Web Application (.war) on tomcat?

后端 未结 5 1891
夕颜
夕颜 2020-12-01 12:13

I have a .war file of a Java Web Application. Now I want to upload it to my ftp server so that I can execute it.

What steps I should perform to run it?<

相关标签:
5条回答
  • 2020-12-01 12:40

    The tomcat manual says:

    Copy the web application archive file into directory $CATALINA_HOME/webapps/. When Tomcat is started, it will automatically expand the web application archive file into its unpacked form, and execute the application that way.

    0 讨论(0)
  • 2020-12-01 12:41

    Log in :URL = "localhost:8080/" Enter username and pass word Click Manager App Scroll Down and find "WAR file to deploy" Chose file and click deploy

    Done

    Go to Webapp folder of you Apache tomcat you will see a folder name matching with your war file name.

    Type link in your url address bar:: localhost:8080/HelloWorld/HelloWorld.html and press enter

    Done

    0 讨论(0)
  • 2020-12-01 12:43
    • copy the .war file in the webapps folder
    • upload the file using the manager application - http://host:port/manager. You will have to setup some users beforehand.
    • (not recommended, but working) - manually extract the .war file as a .zip archive and place the extracted files in webapps/webappname

    Sometimes administrators configure tomcat so that war files are deployed outside the tomcat folder. Even in that case:

    After you have it deployed (check the /logs dir for any problems), it should be accessible via: http://host:port/yourwebappname/. So in your case, one of those:

    http://bilgin.ath.cx/TestWebApp/
    http://bilgin.ath.cx:8080/TestWebApp/
    

    If you don't manage by doing the above and googling - turn to your support. There might be an alternative port, or there might be something wrong with the application (and therefore in the logs)

    0 讨论(0)
  • 2020-12-01 12:47

    As others pointed out, the most straightforward way to deploy a WAR is to copy it to the webapps of the Tomcat install. Another option would be to use the manager application if it is installed (this is not always the case), if it's properly configured (i.e. if you have the credentials of a user assigned to the appropriate group) and if it you can access it over an insecure network like Internet (but this is very unlikely and you didn't mention any VPN access). So this leaves you with the webappdirectory.

    Now, if Tomcat is installed and running on bilgin.ath.cx (as this is the machine where you uploaded the files), I noticed that Apache is listening to port 80 on that machien so I would bet that Tomcat is not directly exposed and that requests have to go through Apache. In that case, I think that deploying a new webapp and making it visible to the Internet will involve the edit of Apache configuration files (mod_jk?, mod_proxy?). You should either give us more details or discuss this with your hosting provider.

    Update: As expected, the bilgin.ath.cx is using Apache Tomcat + Apache HTTPD + mod_jk. The configuration usually involves two files: the worker.properties file to configure the workers and the httpd.conf for Apache. Now, without seeing the current configuration, it's not easy to give a definitive answer but, basically, you may have to add a JkMount directive in Apache httpd.conf for your new webapp1. Refer to the mod_jk documentation, it has a simple configuration example. Note that modifying httpd.conf will require access to (obviously) and proper rights and that you'll have to restart Apache after the modifications.

    1 I don't think you'll need to define a new worker if you are deploying to an already used Tomcat instance, especially if this sounds like Chinese for you :)

    0 讨论(0)
  • 2020-12-01 12:51

    Note that you can deploy remotely using HTTP.

    http://localhost:8080/manager/deploy

    Upload the web application archive (WAR) file that is specified as the request data in this HTTP PUT request, install it into the appBase directory of our corresponding virtual host, and start it using the war file name without the .war extension as the path. The application can later be undeployed (and the corresponding application directory removed) by use of the /undeploy. To deploy the ROOT web application (the application with a context path of "/"), name the war ROOT.war.

    and if you're using Ant you can do this using Tomcat Ant tasks (perhaps following a successful build).

    To determine which path you then hit on your browser, you need to know the port Tomcat is running on, the context and your servlet path. See here for more details.

    0 讨论(0)
提交回复
热议问题