5 Replies Latest reply on Oct 17, 2011 3:04 PM by lostiniceland

    Deploy simple osg-bundles fails because missing org.osgi.util

    lostiniceland

      Hello everyone

       

      Yesterday I was trying to get my first OSGi module deployed on AS 7 (I am currently using 7.0.1 and 7.1 alpha) but the OSGi-subsystem never starts without Errors.

      Since I am currently at work I dont have the stacktrace, but the error was telling me that the package org.osgi.util, which I am importing to use the ServiceTracker, cannot  be found.

       

      I found a blogpost where somebody mentioned to deploy org.eclipse.osgi, org.equinox.util, and so on as well but I I expected that the runtime provided by AS7 is a fully operational OSGi environment. Besides, deploying Equinox failed with other errors.

       

      Some minutes ago, I came across this discussion which says in the end that org.osgi.util has been removed.

       

      I am actually trying to follow the Demo provided by JBoss (Thomas Diesler) but I just cant get it to work :-(

       

      Btw: where can I set up those dependencies from an non-osgi (e.g. EJB) to osgi.

       

      regards

      Marc

        • 1. Re: Deploy simple osg-bundles fails because missing org.osgi.util
          thomas.diesler

          Yesterday I again successfully demoed the OSGi integration at the JBoss One Day Talk. So I'm confident that it works

          Please show me the specific problem - maybe I can see whats going on. org.osgi.util is part of the framework and exported from there. We have lots of tests that use ServiceTracker. Deploying org.eclipse.osgi, org.equinox.util is nonsense. For comprehensive documentation on EJB/OSGi integration monitor JBOSGI-489.

          • 2. Re: Deploy simple osg-bundles fails because missing org.osgi.util
            bosschaert

            I've attached a small working bundle that uses ServiceTracker. The code is as follows:

             

            {code}public class Activator implements BundleActivator {

                private ServiceTracker st;

             

                public void start(BundleContext bundleContext) throws Exception {

                    st = new ServiceTracker(bundleContext, StartLevel.class.getName(), null) {

                        @Override

                        public Object addingService(ServiceReference reference) {

                            Object svc = super.addingService(reference);

                            if (svc instanceof StartLevel) {

                                StartLevel sl = (StartLevel) svc;

                                System.out.println("*** Start Level Service obtained.");

                                System.out.println("    The current Start Level is: " + sl.getStartLevel());

                            }

                            return svc;

                        }

                    };

                    st.open();

                }

             

                public void stop(BundleContext bundleContext) throws Exception {

                    st.close();

                }

            }{code}

             

            You can just deploy that into AS7 (I just dropped it in the deployments folder it with the latest 7.1) and you'll see the service tracker in action:

             

            {code}10:44:27,758 INFO  [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-14) Install bundle: TestServiceTracker:1.0.0

            10:44:27,765 INFO  [stdout] (MSC service thread 1-14) *** Start Level Service obtained.

            10:44:27,765 INFO  [stdout] (MSC service thread 1-14)     The current Start Level is: 1{code}

             

            The attached bundle contains the source code too. This might help you isolate the problem

            • 3. Re: Deploy simple osg-bundles fails because missing org.osgi.util
              lostiniceland

              Thanks a lot to both of you.

               

              When I was posting this question I was using the development builds of JBoss Tools for Eclipse and it seems that the AS has a problem deploying exploded packages. Today I started to use Eclipse for exporting deployable plugins and fragments and it seems to get a little further.

               

              EDIT: I found the problem!

              When using Eclipse Indigo and I add org.osgi.util.tracker, the version of the bundle is automatically 1.5.0.

               

              AS7 only provides 1.4.0, so after I changed that in my Manifest, the bundles are picked up

               

               

              regards

              Marc

              • 4. Re: Deploy simple osg-bundles fails because missing org.osgi.util
                thomas.diesler

                AS7 only provides 1.4.0

                 

                The version of the org.osgi.util package in core 4.2 is 1.4.0. Our version export for that package is correct

                • 5. Re: Deploy simple osg-bundles fails because missing org.osgi.util
                  lostiniceland

                  I didnt want to say that AS 7 is wrong here...maybe the word 'only' is a little bit misplaced ;-)

                   

                  Anyways, I just wanted to point out how the error occured on my system.

                  And thank you Thomas for this awesome Demo: I got my own little example up and running yesterday and it is just brilliant how the BundleContext is injected as resource (makes life much easier).