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?
The context path of the webapp is /mywebapp
Edit
Actually, my ftp server name is ftp://bilgin.ath.cx/ and I have uploaded my TestWebApp.war file to this dir: ftp://bilgin.ath.cx/web
Then what should be the URL to access the index.html page of the webapplication
#2 Edit
Tomcat is listening on 8082
Apache access Tomcat with jk connector.
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 :)
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)
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.
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.
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
Related
I am facing a little strange issue while deploying web service to WAR file.
If I deploy the application via Netbeans IDE it is going under \standalone\deployments directory.
However, if I deploy the war file from Admin Console it is always getting deployed at \standalone\tmp directory.
Please guide on this issue. The deployment should go under \standalone\deployments directory only.
The deployment should go under \standalone\deployments directory only
You are quite not right.
It is not an issue. It is what it is.
standalone/deployment folder stand there only for "hot-deployment" functionality available only with standalone mode.
So, Netbeans uses it. You can do the same just by saving EAR or WAR into standalone/deployment and server will pick it. (default scan interval is 5 sec.)
but Admin console or CLI is only (and standard) way to deploy application on domain. In domain mode deployment folder is not in use and there is no deployment scanner.
Then when you use console it goes common way - deploys as on domain regardless is it domain or standalone server.
Updated / follow-up:
In general it is better to keep .properties file(s) out of deployment, in separate location. It is main idea behind them - to be able to change properties without application rebuilding and redeploying. Usually properties are different in different environments (DEV/UAT/PROD)
So there are 2 most popular solutions:
store properties in different location add that location to class path and access them through ClassLoader.getResourceAsStream() mechanism
store properties in different location, pass that location through system (or -D) variable and access them as file. for JBoss you can place your .properties under configuration directory. there is already JBoss variable. Kind of jboss.config.dir (or such, you can find it in Admin console, I do not have JBoss right now).
But of course sometime it still needed to access resources inside WAR/EAR - in that situation it is pretty much the same as first solution above.
Just be sure your .properties file(s) are accessible through to ClassLoader (in class path) and use them from ClassLoader.getResourceAsStream (or if you use Spring point it as "classpath:" not as "file:".
Is there a way to start/stop .war file from inside another .war?
I'm running SymmetricDS server using Tomcat 8 (it deploys it's own .war) and I need to start it, when a button is pressed and Stop likewise. Can I do that?
When a war file is "dropped" into Tomcat's webapp folder, by default Tomcat automatically deploys it and starts it. When source war file is deleted from the webapp folder, Tomcat automatically stops and undeploys the webapp.
So basically all you need to do is copy and delete the war file to/from the webapp folder to start/stop a webapplication.
Also (or if you can't do this) Tomcat has a built-in manager webapplication which is capable to deploy new applications (from war-files), or to stop and undeploy running web applications.
See Manager App HOW-TO for more details on this.
If you want to do this from your code, check out the ManagerServlet class. You can call it with simple URLs and parameters. The javadoc of the class contains example URLs what you can do with it. Here are 2 important operations specifically to your needs:
/start?path=/xxx - Start the web application attached to context path /xxx for this virtual host.
/stop?path=/xxx - Stop the web application attached to context path /xxx for this virtual host.
I wrote the web application using Spring MVC. When I deploy the app to the server path is localhost:8080/projectName/. It is possible to remove projectName from path from eclipse? I found path in project properties but I cannot find the way how to change it.
I found that I have to change context root to : "/". I changed it but that has no effect.
Thank you for any help.
Regards,
Sebastian
I would break down your question into two parts :
A. Changes to the context root not taking any effect.
For changes to the context root to take effect, you must clean and republish you webapp on your server for the context root changes to get activated. To run "Clean" in context of the server from within eclipse,
Stop the Server
Window -> Show View -> Server -> Right click on your server configuration -> Clean. (Note: To "Clean" the server outside of eclipse, you need to go to the "webapps" directory of your server on your local filesystem and delete the .war file as well as the "project-name" folder which holds the exploded WAR file. )
Deploy your webapp to the server and restart the server.
B. Trying to run your webapp at the context root / - localhost:8080
From what it looks like, you are trying to run your web application at the "Root" of your application server. You haven't mentioned the application server that you are using, but let us for example assume that the server you are using is tomcat. For tomcat, to deploy an application which will run at localhost:8080/ you need to either deploy the exploded war under the "ROOT" directory at $CATALINA_HOME/webapps/ROOT , or name your war file to be root.war.
The $CATALINA_HOME/webapps/ROOT and $CATALINA_HOME/webapps/root.war are special keywords which tell tomcat to deploy the application at content root /.
If you are NOT using tomcat as your application server, then provide more details on the application server being used to see if I can help.
Currently when I deploy a war file to Tomcat it can be downloaded from the URL via something like foo.com/myapp.war.
Most places recommend that you put an entry in a .htaccess file to prevent public access to any war files, or failing that an equivalent entry in your Apache config.
Unfortunately, my host does not provide access to the Apache config (although I can access Tomcat confs) and .htaccess files do not work for all Tomcat/Java related hosting environments. Pretty disappointing. They have been rather unhelpful in this respect.
Without resorting to something like "finding another host" (other than this issue they are fine - I'd rather stay here until my app grows too big), is there anything else I can do to prevent public users accessing my war files, yet still allow Tomcat to deploy the apps when it scans them?
For example, is it possible to specify one directory for Tomcat to scan for war files yet have it deploy the war into the public directories?
Thanks.
It is probably better to ask at https://serverfault.com/. It all boils down to how Tomcat is setup.
The vanilla setup will have a folder called webapps under CATALINE_HOME. You put your WAR archives there (they get auto-extracted and deployed). These folders will not be accessible from HTTP (you cannot download WAR archives from some URL like /webapps/my-test.war). These apps in webapps folder are deployed to some context roots. For example an application my-test.war will by default get deployed as yourhost.com/my-test/.
If you can download your WAR archives from foo.com/myapp.war maybe you can check out what does the CATALINA_HOME/webapp/ROOT app is doing. By default this is deployed under the foo.com. Ask from the host the Tomcat configuration files to figure what kind of custom configurations are they using.
You can place your .war files in any location Tomcat has access to. But you will have to tell Tomcat about it, so it picks them up. You can do this by placing a configuration XML file in
<CATALINA_HOME>/conf/Catalina/localhost/myWebapp.xml
There are samples on what to put into that file myWebapp.xml, e. g. here, step "4)". And of course, the official documentation.
I'm having some trouble uploading and getting my web app on the net with my chosen host. I built a war file in Net Beans and asked my host to deploy it for me. This worked fine but to access it I had to point my browser to:
www.myDomain.co.uk/explodedWar
What of course I wanted was to be able to access it just by pointing my browser at:
www.myDomain.co.uk
The war file contains the whole app, index.html, images, classes etc.
Is this possible or am I missing something ? ?
You can call the war ROOT.war but the best way is to change the context path in the servlet container. To do this in Tomcat you would add the following to your server.xml:
<context path="" docBase="explodedWar" debug="0"/>
If you name your war ROOT.war (in Tomcat) it should do what you want.
This is a question you need to ask your host about since they are deploying it for you.