Hi Dhiego,

 that means that the class loader of the XStream bundle don't have
access to your Project2 class loader. You need to register a composed
class loader to XStream.

 Have a look to this code:
https://github.com/onexus/onexus/blob/develop/org.onexus.resource.serializer.xstream/src/main/java/org/onexus/resource/serializer/xstream/internal/ResourceSerializer.java

 The important part is:
this.xstream.setClassLoader(new RegisteredClassLoader());

 And then at activation time all the bundles that produce classes that
you want to be able to serialize you must register their class loader
using the "register" method.

 I still have one problem with XStream, imagine I serialize an
instance of class A (Project2 bundle) then I reload Project2 bundle
then it's imposible to recover the serialized instance because we have
a new version of class A. May be someone in the list knows a better
aproach.

 Regards,
   Jordi


On Thu, Jan 24, 2013 at 6:34 AM, Dhiego Abrantes de Oliveira Martins
<[email protected]> wrote:
>
> Hi all,
>
> I'm developing a project that uses XStream lib to manipulate XML. There are
> a Project1 that is a service and have a maven dependence to xstream.
>
> The Project2 is a implementation of Project1 and have a transient
> dependency of XStream through Project1.
>
> The Project3 is just a client of Project2, just a consumer.
>
> I can start Project1 and Project2 normally. But, when I start the Project3
> and some method try to use XStream lib, I get that error:
>
> Exception in thread "Thread-12" java.lang.NoClassDefFoundError:
> org/xmlpull/v1/XmlPullParserFactory
> at com.thoughtworks.xstream.io.xml.XppDriver.createParser(XppDriver.java:57)
>  at
> com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:58)
> at com.thoughtworks.xstream.XStream.fromXML(XStream.java:895)
>  at com.thoughtworks.xstream.XStream.fromXML(XStream.java:886)
> at
> br.ufpe.cin.main.ServiceDescriptorImpl.__getServiceDescriptors(ServiceDescriptorImpl.java:24)
>  at
> br.ufpe.cin.main.ServiceDescriptorImpl.getServiceDescriptors(ServiceDescriptorImpl.java)
> at
> ipojo.example.hello.client.HelloClient.__invokeHelloServices(HelloClient.java:94)
>  at
> ipojo.example.hello.client.HelloClient.invokeHelloServices(HelloClient.java)
> at ipojo.example.hello.client.HelloClient.__run(HelloClient.java:54)
>  at ipojo.example.hello.client.HelloClient.run(HelloClient.java)
> at java.lang.Thread.run(Thread.java:722)
> Caused by: java.lang.ClassNotFoundException:
> org.xmlpull.v1.XmlPullParserFactory not found by
> com.springsource.org.xmlpull [53]
> at
> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
>  at
> org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
> at
> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
>  at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
> at
> org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1317)
>  at
> org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1481)
> at
> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1427)
>  at
> org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
> at
> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
>  at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
> ... 11 more
>
> My installed bundles:
> START LEVEL 1
>    ID   State         Level  Name
> [   0] [Active     ] [    0] System Bundle (4.0.3)
> [   1] [Active     ] [    1] Distributed OSGi Distribution Software
> Single-Bundle Distribution (1.3.1)
> [   2] [Active     ] [    1] Apache Felix Bundle Repository (1.4.3)
> [   3] [Active     ] [    1] Apache Felix Configuration Admin Service
> (1.2.6)
> [   4] [Active     ] [    1] Apache Felix EventAdmin (1.2.2)
> [   5] [Active     ] [    1] Apache Felix iPOJO (1.6.0)
> [   6] [Active     ] [    1] Apache Felix iPOJO Arch Command (1.6.0)
> [   7] [Active     ] [    1] Apache Felix Shell Service (1.4.2)
> [   8] [Active     ] [    1] Apache Felix Shell TUI (1.4.1)
> [   9] [Active     ] [    1] Hello Service (1.0.0)
> [  10] [Active     ] [    1] Hello Service Provider (1.0.0)
> [  12] [Active     ] [    1] Adder Service Provider (0.0.1.SNAPSHOT)
> [  13] [Active     ] [    1] Adder Service Interface (0.0.1.SNAPSHOT)
> [  36] [Active     ] [    1] Hello Client (1.0.0)
> [  42] [Active     ] [    1] Thoughtworks XStream (1.4.1)
> [  49] [Active     ] [    1] Service Descriptor Specification (1.0.0)
> [  50] [Active     ] [    1] Service Descriptor Provider (1.0.0)
> [  52] [Active     ] [    1] Java XML Stream API (StAX) (1.0.1)
> [  53] [Active     ] [    1] XMLPULL V1 API (1.1.4.c)
>
> Best regards!
>
> []'s
>
> Dhiego




--
a10! i fins aviat.
J:-Deu

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to