Android Eve
Android Eve

Reputation: 14974

exception has been caught while processing the refactoring 'Rename package'

This refactoring function in Eclipse for package names used to work for me fine until... today:

This is the first time I am receiving this weird Refactoring error, and I have no idea what to make of it:

An exception has been caught while processing the refactoring 'Rename Package'.

Reason: Problems encountered while moving resources.

Click 'Undo' to undo all successfully executed changes of the current refactoring. Click 'Abort' to abort the current refactoring.

What could possibly explain this sudden "change of heart" and how do I fix it?

enter image description here

Upvotes: 10

Views: 23652

Answers (9)

Karthik G
Karthik G

Reputation: 1

Check if the folder location is open in the Command prompt. If yes, then close it and try again.

Upvotes: 0

Ajay Panchal
Ajay Panchal

Reputation: 65

I just restart the computer and start STS(Spring Tool Suite 4) and delete the file/class its works for me.

Upvotes: 0

OmiS
OmiS

Reputation: 31

If it is the problem because of case. I have successfully tried a solution.

  1. This will fail

org.xyz.fileName ---rename---> org.xyz.filename

  1. This will pass

org.xyz.fileName ---rename---> org.abc (rename the structure)

org.abc ---rename---> org.xyz.filename This will work fine!

Upvotes: 0

Pubci
Pubci

Reputation: 4001

Same refactoring problem occurred to me when I was working in the Ubuntu. The cause is the permission limitations. Eclipse cannot re-factor as it does not have permission. After giving root permission, refactoring worked fine for me.

Upvotes: 0

WorkingMonk
WorkingMonk

Reputation: 41

Got the same error. It turns out that my ClearCase (version control) plugin was inactive. Simply activated the version control plugin, and the problem was solved.

Upvotes: 1

Matt
Matt

Reputation: 803

This can be caused if using characters like underscores in your class names (e.g. My_Class.java). The project will build and run fine. But in Eclipse, if you run Android Tools > Rename Application Package, the rename will fail.

Upvotes: 0

Warlock
Warlock

Reputation: 162

Seems from your snapshot that you are running windows 7, maybe vista. If its not a renaming issue, try running eclipse as administrator. It might be permissions-related, but its just a thought.

I see merit behind what Kurru is saying. Windows is not a case-sensitive operating system, meaning that is sees the words Cat and cat as the same thing. When you rename your package, Eclipse creates new directories/folder to put the package in. If you changed the case of your words and not actually rename it, it could throw this error.

Upvotes: 8

Kurru
Kurru

Reputation: 14331

If you're just trying to rename a package to the same name, only with a different case, this error is thrown for me. Very annoying when trying to fix package names to the lowercase convention.

Had some success renaming packages to a step folder, then to the target folder...

ie.

APackage -> apackage FAIL

APackage -> APackage2 -> apackage SUCCESS

Upvotes: 4

Under Windows this is frequently caused by a file or directory being locked. There can be several reasons for this:

  • A file is open in a viewing program outside of Eclipse. Windows will not allow the open file to be refactored.
  • A CMD.EXE is active in one of the directories to be refactored. Windows will not allow the directory to be moved or deleted.
  • A program is running with open files for items in the workspace. Windows will not allow the items to be refactored.

If this is the behaviour of a freshly started Eclipse on a freshly started machine, it is probably not Windows, but a corrupted workspace or Eclipse distribution, and you should unpack a fresh Eclipse and create a new workspace in which you can import (and copy) the existing projects from the old workspace. I don't think this is the problem, though.

Upvotes: 5

Related Questions