title: Servicemix 4, DOSGi, and Zookeeper
body: <p>This is cross posted from the <a href="http://fusesource.com/forums/thread.jspa?messageID=4461" rel="nofollow noreferrer">fusesource forum</a> and the <a href="http://www.nabble.com/forum/ViewPost.jtp?post=25625074&amp;framed=y" rel="nofollow noreferrer">servicemmix forum</a>.</p>
  
  <p>I can't get DOSGi working in FUSE.  I'm trying to get CXF's DOSGi 1.1-SNAPSHOT with Zookeeper discovery onto FUSE 4.1.0.2.  I'm also using Zookeepr 3.2.1.  </p>
  
  <p>Everything works perfectly on Felix 2.0.0.  I just follow the instructions on the <a href="http://cxf.apache.org/dosgi-discovery.html" rel="nofollow noreferrer">DOSGi Discovery</a>  page and then install the <a href="http://cxf.apache.org/dosgi-discovery-demo-page.html" rel="nofollow noreferrer">Discovery Demo</a> bundles.  For DOSGi, I just use the <a href="https://repository.apache.org/content/groups/snapshots/org/apache/cxf/dosgi/cxf-dosgi-ri-singlebundle-distribution/1.1-SNAPSHOT/cxf-dosgi-ri-singlebundle-distribution-1.1-SNAPSHOT.jar" rel="nofollow noreferrer">cxf-dosgi-ri-singlebundle-distribution-1.1-SNAPSHOT.jar</a> for DSW and  <a href="https://repository.apache.org/content/groups/snapshots/org/apache/cxf/dosgi/cxf-dosgi-ri-discovery-singlebundle-distribution/1.1-SNAPSHOT/cxf-dosgi-ri-discovery-singlebundle-distribution-1.1-SNAPSHOT.jar" rel="nofollow noreferrer">cxf-dosgi-ri-discovery-singlebundle-distribution-1.1-SNAPSHOT.jar</a>  for zookeepr discovery.  Then when I start the sample bundles with the sample service impl on one machine, I see the node creation in zookeeper.  Then I start the sample client on another machine and I see the output on the service machine.  Works great.  I do have an warning about an xml error being ignored because some XSD coudln't be found, but it doesn't seem to affect anything. Oh, I also have to install the OSGi compendium bundle first.</p>
  
  <p>When I move to Fuse, I have no such luck.  The OSGi compendium bundle comes with fuse, so no need to install that.  I should just be able to install the dosgi-ri singlebundle, and the dosgi-ri-discovery single bundle, but that doesn't work.  The dosgi-ri singlebundle has all kinds of overlapping bundles with servicemix.  I get an error about port 8081? or whatever the osgi.http.service parameter is, being already in use.  Apparently the dosgi-ri singlebundle comes with pax webservice, which reads the same property as the servicemix http service bundle that comes with servicemix.  Thats when I switch to the  <a href="https://repository.apache.org/content/groups/snapshots/org/apache/cxf/dosgi/cxf-dosgi-ri-multibundle-distribution/1.1-SNAPSHOT/cxf-dosgi-ri-multibundle-distribution-1.1-SNAPSHOT.zip" rel="nofollow noreferrer">cxf-dosgi-ri-multibundle-distribution-1.1-SNAPSHOT.zip</a> and unzip it to take the parts I want.  I take the dsw bundle out of the dosgi-ri multibundle and install that.  No luck because of the jdom dependency.  Then I install the jdom that comes in the ri multibundle, which works fine.  Then go back to dsw, and that installs, so I think i'm getting somewhere.  Time to go back and install the ri-discovery singlebundle.  When I start that I get a pax logging service classcastexception saying it can't be cast to a osgi logservice or something.  But thats just a logging error, and at the bottom it says it can't find the transport class for <a href="http://schemas.xmlsoap.org/soap/http" rel="nofollow noreferrer">http://schemas.xmlsoap.org/soap/http</a>.  Ok, so logging is screwed up and I'm missing some transport class.  Well, clearly this comes from not installing enough from the ri multibundle because it worked on felix.  So what else in there is necessary.  The cxf-minimal-bundle upon inspection has the missing class causing that last error.  So I install that.  Try to start the discovery bundle, but I end up with some kind of corbabroker exception.  Wtf.  Whose using corba in all of this?  Then I go back and undo all of that and try to stick with the singlebundle distros of ri and ri-discovery, but just turn off the servicemix http service.  That crashes servicemix and I can't restart it becauuse the cxf jbi components end up with an unsatisfied dependency.  Odd.  I'll just ignore that because I don't use those anyway, and try to start my samples.  Can't start the samples because it says jetty can't start because the ports already in use.  Doesn't make sense because I shutdown the servicemix http service already. Then I restart jetty.  Works?  Maybe.  My service gets registered and I can browse to the wsdl using firefox, but no registration in zookeeper.  Try to shutdown the ri-discovery bundle and restart it, but I get a nullpointerexception.  Appparently the ri-discovery never actually started up due to one of the aforementioned errors.  Then I started trying to take apart the ri-discovery singlebundle and pull out the internals.  That didn't work because its all apparently necessary, even though theres some libs inside we could do without.</p>
  
  <p>End of the story.  Can't get it to work.  Can anybody else get it to work?  I just want to run the discovery samples in SMX4.  I'm pretty sure its just a bundle conflict problem.  Isn't this what OSGi is supposed to fix???  This is worse than just telling me what jars you depend on and making me setup my classpath.  At least then I'd eventually get the thing running.</p>
  
  <p>My next steps, I think, will be to try again with the ri-multibundle, just the dsw and jdom, plus the ri-discovery singlebundle.  Then I'll try some of the cxf-fuse bundles or some of the cxf-rt bundles to get around the soap transport issue.</p>
  
  <p>Edit notes:  I need more than just showing the DOSGi bundles in an Active state.  They don't actually do much until you try to expose a service through them.  I do need to see multiple machines registering services with a zookeeper instance and other machines consuming those services -- just like the running DOSGi Discovery Sample.  </p>
  
  <p>I've been able to get cxf to expose the distributed service sample as a soap webservice by using the minimal cxf bundle mentioned by either removing parts of the original cxf bundles and restarting the jetty service, and then starting the sample service... or by installing the cxf minimal buundle, then starting my service, then immediately uninstalling the cxf minimal bundle, then restarting jetty... I think that was the order.  Neither of these will work from a clean startup, and having to restart services as a procedure to get DOSGi working is just bad.  I don't even know why installing then uninstalling would do anything -- it shouldn't be leaving any artifacts around.</p>