I am trying to run a OSGI bundle and I am always getting the error Unresolved requirement: Import-Package: org.osgi.service.event
I am using IntelliJ with OSGI plugin
There is my MANIFEST.MF file looks like
Manifest-Version: 1.0
Bundle-Activator: com.project.g.Publisher
Bundle-ManifestVersion: 2
Bundle-Name: pubs
Bundle-SymbolicName: pubs
Bundle-Version: 1.0.0
Bundle-ClassPath: lib/org.osgi.service.event-1.3.1.jar
Export-Package: com.project.g;uses:="org.osgi.framework";version=
"1.0.0"
Import-Package: org.osgi.service.event,org.eclipse.osgi.util,org.apache.felix.gogo.command,
org.osgi.framework,
org.osgi.util.tracker
The Code ( from the example )
public class Publisher extends Thread implements BundleActivator {
Hashtable time = new Hashtable();
ServiceTracker tracker;
@Override
public void start(BundleContext bundleContext) throws Exception {
System.out.println("started");
tracker = new ServiceTracker(bundleContext, EventAdmin.class.getName(), null );
tracker.open();
start();
}
@Override
public void stop(BundleContext bundleContext) throws Exception {
System.out.println("stopped");
}
public void run() {
while ( ! Thread.interrupted() ) try {
Calendar c = Calendar.getInstance();
set(c,Calendar.MINUTE,"minutes");
set(c,Calendar.HOUR,"hours");
set(c,Calendar.DAY_OF_MONTH,"day");
set(c,Calendar.MONTH,"month");
set(c,Calendar.YEAR,"year");
EventAdmin ea =
(EventAdmin) tracker.getService();
if ( ea != null )
ea.sendEvent(new Event("event/start", (Map<String, ?>) time));
Thread.sleep(60000-c.get(Calendar.SECOND)*1000);
} catch( InterruptedException e ) {
return;
}
}
void set(Calendar c, int field, String key ) {
time.put( key, new Integer(c.get(field)) );
}
}
and my project structure
What I am doing wrong here ?
Your bundle seems to be fine. You are only missing a provider of the package org.osgi.service.event at runtime. Try to install the bundle equinox Eventadmin or Felix Eventadmin.