-
1. Re: Deploy simple osg-bundles fails because missing org.osgi.util
thomas.diesler Oct 14, 2011 4:18 AM (in response to lostiniceland)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 Oct 14, 2011 5:49 AM (in response to lostiniceland)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
-
TestServiceTracker_1.0.0.jar 3.5 KB
-
-
3. Re: Deploy simple osg-bundles fails because missing org.osgi.util
lostiniceland Oct 15, 2011 10:28 AM (in response to bosschaert)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 Oct 17, 2011 6:04 AM (in response to lostiniceland)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 Oct 17, 2011 3:04 PM (in response to thomas.diesler)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).