I'm not quite sure what you're trying to accomplish in that way... If the references are not necessary when deserializing, make them transient. If they are necessary, there's something peculiar about your design; is it really necessary that they are implementations of some interface because they're used as services, or are they actually just value objects?
Angelo On Wed, Dec 2, 2009 at 10:49 AM, andrea ziege <[email protected]>wrote: > This is ok I do it the same way: > XStream stream=new XStream(); > stream.setClassLoader(Activator.class.getClassLoader()); > > My problem was that the class I serialize contains references to interfaces > which are visible from my bundle. But the implementation classes are > invisible. This isn't a problem for serialization but for deserialization. > So even DynamicImport doesn't work. So I would need to make the impl > classes > public visible. Which I'm not able in all cases and what is in my opinion a > dirty fix. > Bye, > Andy > > 2009/12/2 Angelo vd Sijpt <[email protected]> > > > Maybe I'm going down the wrong path here, but if your bundle B uses > XStream > > too, you can make use of that. > > XStream will by default use (I believe) the system classloader, and not > the > > classloader of bundle B. You can make it use the correct one by passing > > your > > own classloader: > > > > new XStream(null, new XppDriver(), BundleBClass.class.getClassLoader()); > > > > You should make sure BundleBClass is some class that is loaded by the > > classloader of bundle B, since that has access to the imported classes > from > > bundle A. > > > > Angelo > > > > On Tue, Dec 1, 2009 at 7:44 PM, Ziegenlippe <[email protected] > > >wrote: > > > > > Hello, > > > > > > I cannot find a satisfying solution to a simple looking problem for > quite > > a > > > while. > > > > > > The condensation of the problem: > > > Bundle A > > > the producer stores objects as xml files (e.g. with XStream) > > > it exports the /bundle.a/ package which contains the interface /Item/ > > it > > > contains a private implementation package /bundle.a.impl/ which > contains > > the > > > item implementation class /ItemImpl/ > > > > > > Bundle B > > > the consumer needs to load and process /Item/ instances > > > therefor it imports package /bundle.a/ which contains the /Item/ > > interface > > > > > > Problem: loading Item instances in bundle B leads always to > > > ClassNotFoundExceptions > > > > > > Even working with the last resort /DynamicImport-Package: * / does not > > > solve the problem since it imports only exported packages. > > > > > > From some hints in the internet I got the feeling that this issue is > not > > > really solved for OSGI. Is there any solution known? How deal others > with > > > that issue e.g. ActiveMq which claims to be OSGI compliant. > > > Or am I just on the wrong way? > > > > > > Thank you in advance, > > > Andy > > > > > > > > >

