ClassNotFoundException for case class in Play application

Hi,

I’m working with scala Play application. Aerospike is used as a storage for high load system. I’ve written the code that save and load plenty of data in LDT (LargeList). When running tests everything works just fine. When to call the same methods from the application (from Play Action, which process user request or from Play’s Global object), then I recive Error Code -1: java.lang.ClassNotFoundException: models.Aero.FileEntry, where the last is my model’s case class. What is the reason of such strange behaviour? How can I fix it? Exception arises when calling llist.scan or llist.find. The same code in tests - everything ok.

Yuriy

I faced same kind of problem with java play

Tried with empty constructor but couldnt work.It seems related to class loading behaviour in play.

Exectly what I think! Something wrong with the class loading with Play. As I wrote during tests everything work as it should. It would be very useful to know the reason of this strange behaviour and to know how to make it work. At a moment I have to change the model to avoid Java (scala) objects serialization. This is inconvenient though…

If you put your model classes in seperate project and add it’s published jar as dependency in current project then it will work.

Hi,

FYI, I’ve written a simple To-Do web app using Play, Java, Scala and Aerospike. Here’s the link to detailed blog post on it http://www.iamontheinet.com/2014/10/24/to-do-web-app-using-java-aerospike-play-and-scala. It also has link to the GitHub repo which contains the entire solution.

If you have any questions or feedback, please feel free to reach out to me on skype: iamontheinet

As the name suggests classNotFoundException in Java occurs when JVM (Java Virtual Machine) tries to load a particular class and doesn’t found the requested class in the classpath you specified. This means that, your classpath is broken (which is a very common problem in the Java world ). This problem can be particularly confusing for Java beginners. ClassNotFoundException is a checked exception , so it has to be catch or thrown to the caller.