Reputation:
I did refactor > rename on a project in my workspace, but then when I went under the servers tab and did a right-click > Add and Remove for my Tomcat server in order to modify the resources configured on the server, the resource name for my project is my old project name. I looked everywhere to try and change this, like some sort of Tomcat config file or setting, but I can't find it anywhere. So my project is named one thing, but is configured as a resource on the server under a different name. How do I change this?
Upvotes: 11
Views: 15850
Reputation: 16052
Edit your project name here:
Eclipse -> Project -> Properties -> Web Project Settings -> Context Root
This is where you want to edit the project name (too), and I believe it will also change the project/.settings/org.eclipse.wst.common.component
file as mentioned in Yoni's answer above. I would recommend opening it to verify it though. If so, this is the better answer I believe.
EDIT: Anyone who verifies this, please post, and I'll append your verification to my answer.
2023-MAR UPDATE:
See both Tom Rutchik's reply and smat88dd's answer. Tom details this method does not change the "wb-module deploy-name" nor the property "java-output-path" in the org.eclipse.wst.common.component file. And smat88dd's answer of editting the org.eclipse.wst.common.component file manually may be the answer.
Upvotes: 6
Reputation: 9568
Added images and some information to @Yoni post.
Eclipse tomcat Add Remove still shows old project name. Bug 180741
File: D:\Yashwanth\MyProject.settings\org.eclipse.wst.common.component
Tomcat: MyProject(MyOldProject)
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="MyOldProject">
<property name="context-root" value="MyProject"/>
<!-- ... -->
</wb-module>
</project-modules>
How it looks like when you add a resource from eclipse.
To resolve the issue change from deploy-name="MyOldProject"
to deploy-name="MyProject"
. After changing you will see in Tomcat as MyProject
Upvotes: 0
Reputation: 1177
Same issue and resolved it by changing manually deploy-name in project/.settings/org.eclipse.wst.common.component
file and editing Context root in Eclipse -> Project -> Properties -> Web Project Settings -> Context Root
. I have not encountered the issue since I did the trick.
Upvotes: 0
Reputation: 648
The other answers didn't fix my issue. Deleting and then recreating my tomcat server worked. If you're still having issues run this command from a unix based terminal.
grep -Ril 'yourOldProjectName' 'C:\EclipseWorkspace\yourProjectsDir'
This will look through your entire project for your old project name. The output is the file names of all the files that have your old project name.
Upvotes: 0
Reputation: 1204
Answering Xonatron's message: changing the context root only changes the URL requested to reach the app. To change the 'resource name' as displayed in Eclipse you have to manually update the file project/.settings/org.eclipse.wst.common.component AND refresh the Eclipse project (F5).
Upvotes: 0
Reputation: 2388
Unfortunately, changing the Context Root does not update the org.eclipse.wst.common.component-file. So it is really necessary to change the deploy name in the file.
Upvotes: 2
Reputation: 10321
I believe you are looking for a hidden pref located under your project/.settings/org.eclipse.wst.common.component
.
The beginning of the file should look roughly like this:
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="projectB">
So just change the deploy-name. Another thing that I recommend changing is the project's context root, right-click the project -> Properties -> Web Project Settings.
(just to clarify, to the best of my understanding this behavior is a bug in WTP. WTP is responsible for maintaining the hidden pref file under .settings, and it just doesn't update the file when the project is renamed)
Upvotes: 37