Eclipse: ClassFile cannot be cast to ICompilationUnit

Today, checking out from the repository, I got this error message from Eclipse:

org.eclipse.jdt.internal.core.ClassFile cannot be cast to org.eclipse.jdt.core.ICompilationUnit

To save anybody getting the same message from wondering and poking around what it means, here is the simple reason. A colleague had accidentally checked in a .class file in a source folder, causing my Eclipse to try and process (compile) this presumed Java source file.

Deleting it from disk made the problem go away. Thinking about installing a pre-commit hook on the repository server to prevent this from happening again.

Comments

Anonymous said…
Or delete the Manifest folder that gets created if you bring in files using a jar file.
Jon said…
I had this same problem with Mylyn. I deleted the jar files (which shouldn't have been there since I uninstalled it) and everything was functioning again.


Thanks!

Popular posts from this blog

SAXParseException: -1:-1: Premature End Of File - Misleading error

Can't start server: Bind on TCP/IP port: No such file or directory

FindBugs - Writing custom detectors (Part 1)