I was using Eclipse to run my project’s unit tests and I received this error right away:
The project: MyDependantProject which is referenced on the classpath, does not exist.
I took a look at my projects Java Build Path configuration, and “MyDependantProject” was listed there.
Next, I took a look at the JUnit Run Configuration. This was more alarming as look at the blank line. That was where I should have saw “MyDependantProject” listed:
I went back to my Java Build Path and I removed “MyDependantProject” in attempt to force a different error (as I thought once I re-added it, that blank line above would go away). This time when I ran my unit tests, I received this error:
org.eclipse.jdt.internal.core.JavaModel cannot be cast to org.eclipse.jdt.core.IJavaProject
The combination of these two errors made me reflect upon my workspace. I knew I had just created this Eclipse workspace the other day. I looked a little closer and I realized that the name of my workspace was the same as the name of one of my projects in the workspace.
Searching Google, you will find doing this will cause a myriad of problems that manifest in different ways. So my solution was just to rename my workspace to something that was not the name one of the projects.