开发者

Why when I rename a project in Eclipse does Tomcat not pick up the new resource name?

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?


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)


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.


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.


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).


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.


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.


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.

Why when I rename a project in Eclipse does Tomcat not pick up the new resource name?

To resolve the issue change from deploy-name="MyOldProject" to deploy-name="MyProject". After changing you will see in Tomcat as MyProject

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜