New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResourceFactories and Segmented ClassLoaders #153
Comments
I think I've worked around this in the past by using the Thread context classloader for loading classes that need to be visible to different OSGi bundles. @madjam What do you think? Edit: A bit of reading and the above seems like a bad idea. A few other potential options might be allowing the ClassLoader to be specified in the API as part of configuration, or using a bridge ClassLoader internally, similar to what Guice does, bridging the visibility of loaded classes between the library and the client's classes. |
@jhalterman That is a good suggestion. The trouble I see in this context is that the Thread doing the deserialization is the thread that is created here: https://github.com/atomix/copycat/blob/master/server/src/main/java/io/atomix/copycat/server/CopycatServer.java#L969. And that thread's ClassLoader is not aware of the custom ResourceFactory (a quick test confirms this) |
Neil Bartlett seems to have the authoritative solutions we can choose from here: http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html (scroll down to the solutions section). I forgot that the bridge classloader idea still requires the user to pass a reference to the Class they want to load, which is how Guice obtains the user's classloader reference. |
This is a good list. |
It would be great to have OSGi support. I have a provisional fix for this issue. It involves adding |
Alright... I'm working on a solution for the |
@madjam that would be great actually that's exactly what I was thinking before I read your comment :-) |
Nevermind I think you're saying the |
Thanks @kuujo. My thoughts were in line with your suggestion. I opened a PR for this: atomix/catalyst#40 |
#158 is the Atomix PR to simply the serialization logic in |
Resolved via atomix/catalyst#40 and #158 |
With recent changes that introduce ResourceFactories, I'm having trouble creating a custom resource. The custom resource and its classes are defined in a bundle A and Atomix classes are in bundle B. They don't share class loaders.
As a result deserialization code in https://github.com/atomix/atomix/blob/master/resource/src/main/java/io/atomix/resource/ResourceType.java#L83 fails with a
ClassNotFoundException
@kuujo: Is it possible to have this be compatible with a OSGi environment where there are multiple class loaders?
The text was updated successfully, but these errors were encountered: