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.
Related
When I'm running my web-application in tomcat and of course it's classes having tomcat working directory, because the JWM was started there. But is there any way to configure tomcat, as all classes of each deployed application, will have the application directory as their working directory?
You don't have to configure Tomcat working directory. You can get your application root directory from your servlet by calling :
String root = getServletContext().getRealPath("/");
Note that this folder is accessible from client browser.
If you want a working directory that is inaccessible from client, create a folder inside WEB-INF
String privateRoot = getServletContext().getRealPath("/WEB-INF");
You can change Tomcat's startup scripts. The tomcat process inherits whatever the current directory was for the startup script. To make tomcat start in a different working directory, you'll have to figure out what is launching tomcat, and change that process to change to the desired directory before it runs startup.sh.
You can look here on how to setup the working directory.
I have a server where is running my web-application, located in the root folder (you can see it in the image, the path is /).
I reach that application by typing the IP and the Port (for example 111.222.333.444:1234).
Now I'm trying to deploy another web-application and reach it by typing 111.222.333.444:1234/prova/index.jsp (you can see it in the image, the path is /prova).
By using Tomcat Web Application Manager I uploaded a new war file called prova.war.
But, when I try to start it by clicking the start button, it doesn't start. In fact, when I click the start button, the Tomcat Web Application Manager I get the message:
FAIL - Application at context path /prova could not be started
.
If I use a ftp client, I can see that prova.war was correctly (I assume) unpacked.
Thank you.
Please check the log file. I.e you can check catalina.out file may be there are some issues while deploying the your new application (i.e prova)
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.
My .war application runs on TomCat
I am able to deploy my .war application to a specific directory e.g. www.abc.com/specific
I would do this by renaming my application specific.war and then going to Tomcat Web Application Manager and then going to "WAR file to deploy", select my WAR file and deploy it.
However I would like to deploy it so that if the user types www.abc.com he/she will go straight to the application, without specifying the directory.
How is this possible? Thanks [I have tried calling the application root.war]
Two ways:
name the war file ROOT.war
specify the context path attribute in META-INF/context.xml - see here
I solved this by using forwarding/masking (through the domain name provider)
I forwarded www.abc.com to www.abc.com/specific
and I masked so that "specific" is not shown
I am not sure if this answers your question. But I believe u can automatically navigate to the page u want using the
<welcome-file></welcome-file>
in the web.xml file of ur web app.
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