0

I had a package structure which I changed, and this lead to the corresponding folders in /bin/ being removed, so now I get a ClassNotFoundException.

More specifically, I had the ususal /src/ and /bin/, and inside /src/ I had /main and /test, and this was presumably mirrored in /bin/. I shuffled the files around a bit and ended up with /main/model/ and /test/model/.

I have tried to manually create the corresponding folders (mirroring the packages in /src/), but this does not seem to help. I managed to compile the classes in one of the packages, but not in the test package, since it uses ScalaTest* and I didn't manage to compile the classes with the scalatest jar file (or something was wrong with the classpath).

So my question is:

  • How do I fix this within this peoject? (I don't want to simply create a new project and copy the source files over)
  • I'm guessing that I should learn more about build systems to be more resilient to such annoyances in the future? If so, what should I read up on, specifically to become better at troubleshooting and having more fine grained control over the build in the context of IDEs in the future (making builds independent of IDEs is not a priority for me at this point)?

An answer to one of these questions would be sufficient.

*All the source files are .scala files, if that might matter.

Udate

I did a clean of the project (project -> clean). This seemed to fix the problem: I was able to run the test classes from within Eclipse. All the binary files were in there, too. I made a new package, main.controller, with one class, and when I tried to run it, it said that it couldn't find the class. I tried to run the tests again, but those gave me a ClassNotFoundException, too. When I looked in /bin/ it turned out that all the folders and files were gone. I've tried to clean the project again but to no avail. I don't understand how I was able to clean the project, but now it can't fix it?

Update 2

To test if this was reproducible with a Java project, I made a Java project with two packages; main and test. I had the main class in main, which used a class from test (so there were dependencies across the packages). It ran succesfully. Then I added packages so that I had main.model and test.model and moved the corresponding files there. It also ran. Then I tried to delete all the files and folders in /bin/, and then the main class would not run. But if I did a clean of the project, then it cleaned it succesfully and the Main class was able to run. Then I made a Git repository for it, placing it outside of /workspace/ (in my git folder) and tried to do the same there. Eclipse was able to clean the project succesfully everytime.

So I don't understand why it can't manage to clean my Scala project.

Guildenstern
  • 2,179
  • 1
  • 17
  • 39
  • Seems to be a refactoring problem. Did you respectively change all the import's of the classes in the changed packages? – Dhrubajyoti Gogoi May 25 '13 at 20:24
  • @Dhrubajyoti yes, all the source files have the correct package declaration at the top line. If that was your question? It's true that the automatic refactoring in Eclipse for Scala is pretty brittle, but I managed to fix the things that it messed up. – Guildenstern May 26 '13 at 08:39

1 Answers1

0

I had errors in the "Problems" tab (Window -> Show View -> Problems). Now that I've made them go away, my /bin/ is correct and I can run both my Main class and my tests. This Question helped find out what the problem was:

Scala project won't compile in Eclipse; "Could not find the main class."

Community
  • 1
  • 1
Guildenstern
  • 2,179
  • 1
  • 17
  • 39