Java - How to change context root of a dynamic web project in Eclipse?
|
82
|
I'm sure you've moved on by now, but I thought I'd answer anyway. Some of these answers give work-arounds. What actually must happen is that you clean and republish 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.datunless, 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. (1) In your project's Properties, choose "Web Project Settings". (2) Change "Context root" to "app".
(3) Choose Window > Show View > Servers. (4) Stop the server by either clicking the red square box ("Stop the server" tooltip) or context-click on the server listing to choose "Stop". (5)On the server you want to use, context-click to choose "Clean…".
(6) Click OK in this confirmation dialog box.
Now you can run your app with the new "app" URL such as: 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/ Thanks so much to Russ Bateman for posting the correct answer to this frustrating problem. Vaadin toolkit programmers may need to rebuild their widget set if using visual add ons. --Basil Bourque |
||||||||
|
|
16
|
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). |
||||
|
|
12
|
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:-
Here, you can just change your project context path to something else. Hope this helps. |
||||||||
|
|
6
|
I tried out solution suggested by Russ Bateman Here in the post
But Didnt worked for me as I needed to have a *.war file that can hold the config and not the individual instance of server on my localmachine. In order to do that I need jboss-web.xml placed in WEB-INF
|
||||||||
|
|
4
|
Apache tomcat keeps the project context path in server.xml path. For each web project on Eclipse, there is tag from there you can change it. I have one project for there on context root path in server is:
This path represents context path of your web application. By changing this path, your web app context path will change. |
|||
| add comment |
|
1
|
In the java project, open .settings folder. there locate the file named "org.eclipse.wst.common.component" . Change tag <wb-module deploy-name="NEW_NAME"> . Also you may want to change context root in project properties |
||
| add comment |
|
1
|
In Glassfish you must also change the file WEB-INF/glassfish-web.xml
So when you click in "Run as> Run on server" it will open correctly. |







浙公网安备 33010602011771号