Re: Using XStream in OSGi Project

2013-01-24 Thread Jordi Deu-Pons
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
dhiegoabran...@gmail.com 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: 

Re: Using XStream in OSGi Project

2013-01-24 Thread Dhiego Abrantes de Oliveira Martins
Thanks Jodi!

Is the best approach to work with xstream? Can I just start xstream bundle?

I'm was trying to find some approach more 'automatic', like: a) embbed into
project1


Abs,
__
*Dhiego** **Abrantes** de Oliveira Martins*
*Computer Science, M.Sc. Candidate at UFPE*
www.dhiegoabrantes.com
+55 83 .1081
***Any fool can write code that a computer can understand. Good programmers
write code that humans can understand*. (Martin Fowler)


2013/1/24 Jordi Deu-Pons jo...@jordeu.net

 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
 dhiegoabran...@gmail.com 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 ] [

Re: Using XStream in OSGi Project

2013-01-24 Thread Dhiego Abrantes de Oliveira Martins
Thanks Jordi!

Is the best approach to work with xstream? Can I just start xstream bundle?

I'm was trying to find some approach more 'automatic', like: a) embbed
xstream libs into project1; or just install xstream bundles in container to
project1 use it automatically;

The classloader solution is a workaround?

Best regards!


[]'s

Dhiego


2013/1/24 Jordi Deu-Pons jo...@jordeu.net

 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
 dhiegoabran...@gmail.com 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] 

Is it safe to use the same dictionary to register multiple services ?

2013-01-24 Thread Christopher BROWN
Hello,

I am implementing a bit of code with Apache Felix and in a specific code
block, I register multiple services, all with the same non-default service
ranking.

I read the registering services part of the OSGi 4.3 specifications, and
it seems to suggest that implementations will copy the service properties
(changes to the properties object may not be applied, use setProperties()
instead...).  The wording does suggest though that this behavior is
implementation-specific.

Should I create a new Dictionary object for each service registered, or can
I reuse the same instance?  I'd prefer an authoritative answer as opposed
to just observing behavior with a specific implementation.

For example, if the implementation used the supplied properties internally,
it could for example add the object class and service id ; if I reused the
instance, things could get mixed up.

Thanks,
Christopher


osgi.identity namespace issues with Apache Aries subsystem impl and Felix-4.1.0-Snapshot

2013-01-24 Thread Christian Berger
Hi,

 

I've got some trouble while I was playing with Apache Aries Subsystem and
Felix 4.1.0-Snapshot. After further investigation, I was able to find out
that my instance of BundleRevision doesn't belong to the namespace
osgi.identity. So my question is: Are you still implementing the new
namespace features? When I check svn I cannot see much activity, thus I
guess you are almost done with Felix 4.1? 

 

It would be nice if somebody could have a statement on this.

 

Thanks in advance

 

Cheers

 

Christian



Re: Using XStream in OSGi Project

2013-01-24 Thread Jordi Deu-Pons
 The classloader solution is a workaround?
I don't think it's a workaround. Because of the OSGi class loading
mechanism, there is a need to use the correct class loader when you
are unserializing your class instance. I don't known if there is a
better way to do this.


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

-
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org



Re: Is it safe to use the same dictionary to register multiple services ?

2013-01-24 Thread Richard S. Hall

On 1/24/13 06:42 , Christopher BROWN wrote:

Hello,

I am implementing a bit of code with Apache Felix and in a specific code
block, I register multiple services, all with the same non-default service
ranking.

I read the registering services part of the OSGi 4.3 specifications, and
it seems to suggest that implementations will copy the service properties
(changes to the properties object may not be applied, use setProperties()
instead...).  The wording does suggest though that this behavior is
implementation-specific.

Should I create a new Dictionary object for each service registered, or can
I reuse the same instance?  I'd prefer an authoritative answer as opposed
to just observing behavior with a specific implementation.

For example, if the implementation used the supplied properties internally,
it could for example add the object class and service id ; if I reused the
instance, things could get mixed up.


Well, the JavaDoc says changes should not be made to this object, which 
could imply that the framework now owns the dict after registering a 
service.


And here under registering services the spec says:

   Using the ServiceRegistration object is the only way to reliably
   change the service object’s properties after it has been registered
   (see setProperties(Dictionary)). Modifying a service object’s
   Dictionary object after the service object is registered may not
   have any effect on the service’s properties.

This implies that it is up to the framework as to whether it copies or not.

So, I am thinking you should make copies yourself to be safe, even 
though I think most frameworks do make copies already.

OSGi Core Release 5
- richard



Thanks,
Christopher





Re: osgi.identity namespace issues with Apache Aries subsystem impl and Felix-4.1.0-Snapshot

2013-01-24 Thread Richard S. Hall

On 1/24/13 07:44 , Christian Berger wrote:

Hi,

  


I've got some trouble while I was playing with Apache Aries Subsystem and
Felix 4.1.0-Snapshot. After further investigation, I was able to find out
that my instance of BundleRevision doesn't belong to the namespace
osgi.identity. So my question is: Are you still implementing the new
namespace features? When I check svn I cannot see much activity, thus I
guess you are almost done with Felix 4.1?

  


It would be nice if somebody could have a statement on this.


We're working on getting 4.2 (4.1.0-SNAPSHOT will be released as 4.2) 
this month. It will does not include much R5 functionality, but it will 
move to the R5 API, thus making it easier to add patches for R5 
functionality.


Adding the osgi.identity namespace to bundles should be fairly 
straightforward after that. Feel free to open up an issue requesting it.


- richard



  


Thanks in advance

  


Cheers

  


Christian





-
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org



Re: Felix Event Admin Service and Configuraion Change Events

2013-01-24 Thread Felix Meschberger
Hi,

There seems to never have been a release of this bundle -- apparently nobody 
ever needed it ... interesting...

So you can get it from the source repository and build it yourself. (Maybe it 
is not update to date the recently added LOCATION_CHANGED event is missing.

Regards
Felix

Am 24.01.2013 um 12:16 schrieb Weisenborn, Christopher M:

 Currently configuration change events are not posted through the event
 admin service. The following link states that there is supposed to be an
 Apache Felix EventAdmin Bridge Configuration  that should handle
 bridging these events to the event admin. However I have been unable to
 find it and was wondering if anyone knows where this bridge code is or
 if it event exists at this time?
 
 
 
 Link:
 http://apache-felix.18485.n6.nabble.com/Felix-Event-Admin-Service-and-Co
 nfiguraion-Change-Events-td4836424.html
 
 
 
 Thanks,
 
 
 
 Chris Weisenborn
 
 Junior Software Technician
 
 Sensor System Division (SSD)
 
 University of Dayton Research Institute
 
 
 


-
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org