How to change context root of a dynamic web project in Eclipse?
I'm sure you've moved on by now, but I thought I'd answer anyway.
Some of these answers give workarounds. What actually must happen is that you clean and re-publish your project to "activate" the new URI. This is done by right-clicking your server (in the Servers view) and choosing Clean. Then you start (or restart it). Most of the other answers here suggest you do things that in effect accomplish this.
The file that's changing is workspace/.metadata/.plugins/org.eclipse.wst.server.core/publish/publish.dat
unless, that is, you've got more than one server in your workspace in which case it will be publishN.dat
on that same path.
Hope this helps somebody.
Not sure if this is proper etiquette or not — I am editing this answer to give exact steps for Eclipse Indigo.
-
In your project's Properties, choose Web Project Settings.
-
Change Context root to app.
-
Choose Window > Show View > Servers.
-
Stop the server by either clicking the red square box ("Stop the server" tooltip) or context-click on the server listing to choose "Stop".
-
On the server you want to use, context-click to choose "Clean…".
-
Click OK in this confirmation dialog box.
Now you can run your app with the new "app" URL such as:
http://localhost:8080/app/
Doing this outside of Eclipse, on your production server, is even easier --> Rename the war file. Export your Vaadin app as a WAR file (File > Export > Web > WAR file). Move the WAR file to your web server's servlet container such as Tomcat. Rename your WAR file, in this case to app.war. When you start the servlet container, most such as Tomcat will auto-deploy the app, which includes expanding the war file to a folder. In this case, we should see a folder named app. You should be good to go. Test your URL. For a domain such as *example.com" this would be:
http://www.example.com/app/
Vaadin toolkit programmers may need to rebuild their widget set if using visual add ons.
After changing the context root in project properties you have to remove your web application from Tomcat (using Add and Remove... on the context menu of the server), redeploy, then re-add your application and redeploy. It worked for me.
If you are struck you have another choice: select the Tomcat server in the Servers view. Double clicking on that server (or selecting Open in the context menu) brings a multipage editor where there is a Modules page. Here you can change the root context of your module (called Path on this page).
If you are running Tomcat from Eclipse, it doesn't use the configuration from your actual Tomcat installation. It uses the Tomcat configuration that it created and stored under "Servers" project. If you view your Eclipse workspace, you should see a project called "Servers". Expand that "Servers" project and you will come across server.xml. Open this file and scroll all the way to the bottom, and you should see something like this:-
<Context docBase="abc" path="/abc" reloadable="true" source="org.eclipse.jst.jee.server:abc"/>
Here, you can just change your project context path to something else.
Hope this helps.