I made an maven-osgi project where an activator should send an osgi event but for some reason EventAdmin is always null.
Here is my java class
package co
You have implemented a classic anti-pattern in OSGi: you assume that the EventAdmin service will already be available when your bundle starts. This is an inherently unsafe assumption because your bundle might in fact be started before the bundle that provides the EventAdmin service.
There is a wrong way and a right way to fix this. The wrong way is to insist that your bundle must be started after EventAdmin. That way leads to start-order dependencies and extreme fragility. See: http://wiki.osgi.org/wiki/Avoid_Start_Order_Dependencies
The right way is to use a framework such as Declarative Services (DS) to declare a component inside your bundle that references the EventAdmin service. Then DS will activate your component and inject it with the EventAdmin instance as soon as it becomes available. See: http://wiki.osgi.org/wiki/Declarative_Services