Expand my Community achievements bar.

SOLVED

Declarative Service Component state failed activation with null pointer exception

Avatar

Level 1

While migrating from felix annotations to osgi annotations , we are facing error in multiple component where all the components state are failed activation , throwing following error 

 

java.lang.NullPointerException at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:277) at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114) at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:982) at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:955) at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:900) at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:348) at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:248) at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:350) at org.apache.felix.framework.Felix.getService(Felix.java:3954) at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:450) at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:86) at org.apache.felix.scr.impl.inject.BindParameters.getServiceObject(BindParameters.java:47) at org.apache.felix.scr.impl.inject.field.FieldHandler$ReferenceMethodImpl.getServiceObject(FieldHandler.java:519) at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2308) at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.prebind(DependencyManager.java:1154) at org.apache.felix.scr.impl.manager.DependencyManager.prebind(DependencyManager.java:1568) at org.apache.felix.scr.impl.manager.AbstractComponentManager.collectDependencies(AbstractComponentManager.java:1029) at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:935) at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:756) at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:1045) at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:999) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) at org.apache.felix.framework.Felix.registerService(Felix.java:3804) at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:906) at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:892) at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128) at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:959) at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:732) at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:1045) at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:999) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) at org.apache.felix.framework.Felix.registerService(Felix.java:3804) at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:501) at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.registerFactory(ResourceResolverFactoryActivator.java:497) at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.checkFactoryPreconditions(ResourceResolverFactoryActivator.java:560) at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.access$100(ResourceResolverFactoryActivator.java:73) at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator$1.providerAdded(ResourceResolverFactoryActivator.java:394) at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.register(ResourceProviderTracker.java:217) at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.access$200(ResourceProviderTracker.java:59) at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker$1.addingService(ResourceProviderTracker.java:130) at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker$1.addingService(ResourceProviderTracker.java:106) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:871) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903) at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) at org.apache.felix.framework.Felix.registerService(Felix.java:3804) at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:335) at org.apache.sling.bundleresource.impl.BundleResourceProvider.registerService(BundleResourceProvider.java:69) at org.apache.sling.bundleresource.impl.Activator.addBundleResourceProvider(Activator.java:139) at org.apache.sling.bundleresource.impl.Activator.bundleChanged(Activator.java:96) at org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915) at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834) at org.apache.felix.framework.EventDispatcher.run(EventDispatcher.java:1147) at org.apache.felix.framework.EventDispatcher.access$000(EventDispatcher.java:54) at org.apache.felix.framework.EventDispatcher$1.run(EventDispatcher.java:102) at java.base/java.lang.Thread.run(Thread.java:834)

 

What could be the reason for the above error ? Kindly help me

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Thanks, could you confirm if you are still using mvn-scr-plugin, as far as I know it should be removed during migration from felix to OSGi annotations. Maven bundle plugin should be enough.

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @manishk62815370, could you please share some example source code of component (that is not working) after migration from felix to osgi annotations?

Avatar

Level 1

Hi @lukasz-m , please find example code below... couldn't post all the code so just mentioned only example.  

 

@Component(immediate = true, name = "AuthenticationManager", service = AuthenticationManager.class,
property = {"service.description = authenticationManager.manager.description"})
public class AuthenticationManagerImpl implements AuthenticationManager{


// to read configuration from osgi
@Reference
ConfigurationManager configManager;


//implementation for all the 3 methods from below interface

}

public interface AuthenticationManager {
public void getAuthenticationResponse(ResourceResolver resolver);
public List<String> getAuthorizedAttributes(ResourceResolver resolver,String attribute);
public Map<String, String> getAuthorizedAttributesMap(ResourceResolver resolver,
String attribute);
}

 

do you think it may be an issue with the implementation we have?

Avatar

Correct answer by
Community Advisor

Thanks, could you confirm if you are still using mvn-scr-plugin, as far as I know it should be removed during migration from felix to OSGi annotations. Maven bundle plugin should be enough.

Avatar

Level 1

thanks @lukasz-m for the input, i will check once again for the plugins we used in our project and try removing mvn-scr-plungin

Avatar

Community Advisor

Hi @manishk62815370 ,

     Did you removed your scr annotations depedency from pom.xml and please add the latest OSGi annotations depedency.

 

Kr,

Sanjay