Closed kwalcock closed 4 years ago
There is evidence that the problem is with the play framework class loader (https://groups.google.com/forum/#!topic/play-framework/CzLGIYnP8To). It might be helpful if a different class loader could be passed in as an argument.
Hi @kwalcock
I made it possible to define your own classloader when loading the index and released the lib as 0.0.46
Can you check if this solves your problem if you use it with the classloader from play.Environment ?
Thank you! I will try it out ASAP. A play app can be run in (at least) two ways from within sbt: with run and runProd. With the old code, neither worked. sbt can also be used to stage the app for use outside of sbt. That one uses the normal classloader and did work with your library and it was going to be the workaround. With your changes I hope to be able to run code directly from sbt (or IntelliJ). It will be very helpful.
Hartelijk dank. Het blijkt te werken. The default value of Thread.currentThread.getContextClassLoader
seems to suffice, so all I needed to do was change from load
to loadFromFile
.
I have a Scala application which uses an index created by hnswlib and it works great. When I call the exact same code from a play webapp, the deserialization of the TId fails for some reason
I can deserialize this type from elsewhere in the application, even in a webapp, just not during the HnswIndex.load in the same webapp.
Any ideas? Sometimes it is a ClassLoader problem and I vaguely recall seeing an implementation in the code of this repo or one nearby.