Bundle Activation Error | Community
Skip to main content
Level 4
April 28, 2017
Solved

Bundle Activation Error

  • April 28, 2017
  • 5 replies
  • 2819 views

Hi,

I am working on AEM 6.2

As loginAdministrator is depcreated.

So i followed the link: http://adobeaemclub.com/access-to-resourceresolver-in-osgi-services-aem-6-1/

I used following code in osgi-bundle:

I created the service user and mapped as mention above link .

 

Map<String,Object> paramMap = new HashMap<String,Object>();
            //Mention the subServiceName you had used in the User Mapping
            paramMap.put(ResourceResolverFactory.SUBSERVICE, "readService");
            log.info("After the param");
            ResourceResolver rr = null;
            try{
                  rr = resourceFactory.getServiceResourceResolver(paramMap);

                Session session =rr.adaptTo(Session.class);

             }

 

 

When osgi-bundles imported in console/bundles:

Following Exception is thrown:-

 

error.log:

 

28.04.2017 13:28:39.419 *INFO* [OsgiInstallerImpl] org.apache.sling.installer.core.impl.tasks.BundleStartTask Could not start bundle com.adobe.connect.osgi.service.connect-osgi-service [475]. Reason: {}. Will retry.
org.osgi.framework.BundleException: Activator start error in bundle com.adobe.connect.osgi.service.connect-osgi-service [475].
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2276)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)
    at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:93)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.doExecuteTasks(OsgiInstallerImpl.java:847)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:689)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:265)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: null
    at com.adobe.connect.osgi.service.Activator.start(Activator.java:85)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2226)
    ... 8 common frames omitted

 

Any Suggestion?

 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Follow this artilce and watch the video. For AEM 6.1 and 6.2 - you need to use a system user. 

http://scottsdigitalcommunity.blogspot.ca/2014/12/querying-adobe-experience-manager-6.html

This will show you the proper way. 

5 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
April 28, 2017

Follow this artilce and watch the video. For AEM 6.1 and 6.2 - you need to use a system user. 

http://scottsdigitalcommunity.blogspot.ca/2014/12/querying-adobe-experience-manager-6.html

This will show you the proper way. 

Level 4
April 29, 2017

smacdonald2008 wrote...

Follow this artilce and watch the video. For AEM 6.1 and 6.2 - you need to use a system user. 

http://scottsdigitalcommunity.blogspot.ca/2014/12/querying-adobe-experience-manager-6.html

This will show you the proper way. 

 

I created system user.

Not able to fix this issue..

joerghoh
Adobe Employee
Adobe Employee
April 29, 2017

Hi,

Sadly you did not provide the exact line in your code, so it's hard to map Activator.java, line 85 to a statement.

My gut feeling says, that the resource factory is null. Likely you tried to inject this dependency via @Reference. But guessing from the filename "Activator" you try to do that in the bundle activator. And AFAIK this reference does not work in Bundle activators, but only in SCR components.

Can you confirm my assumptions?

Cheers,
Jörg

Level 4
April 29, 2017

That is my code

 

class Activator{

@Reference private ResourceResolverFactory resourceFactory; public void start(BundleContext context) { String url = null; SlingRepository repository = null; ServiceReference repositoryServiceRef = context.getServiceReference(SlingRepository.class.getName()); Session jcrSession = null; log.info("1 line"); if (repositoryServiceRef != null) { log.info("2 line"); repository = (SlingRepository) context.getService(repositoryServiceRef); log.info("3 line"); try { log.info("4 line"); Map<String,Object> paramMap = new HashMap<String,Object>(); //Mention the subServiceName you had used in the User Mapping paramMap.put(ResourceResolverFactory.SUBSERVICE, "readService"); ResourceResolver rr = null; try{ log.info("5 line"); rr = resourceFactory.getServiceResourceResolver(paramMap); log.info("6 line"); } catch(Exception e){ log.error(e.getMessage()); } jcrSession = rr.adaptTo(Session.class); log.info("7 line"); Node clusterPropertiesNode = jcrSession.getNode("/content/query/c1/jcr:content"); log.info("8 line"); url = clusterPropertiesNode.getProperty("serverUrl").getString(); log.info("9 line"); // Perform Post Install Tasks performPostInstallTasks(jcrSession, context); } catch (RepositoryException e) { log.error("Error retreiving connect cluster configuration node", e); } finally { jcrSession.logout();// this is line no 85 } }

}

 

In error.log file:

1 line

2 line

3 line

4 line

5 line

then exception...

joerghoh
Adobe Employee
Adobe Employee
April 30, 2017

Hi,

yes, that's the problem. You try to use the @Reference annotation in the bundle activator, which does not work, because the Activator is not a SCR component. If you follow the documentation at [1] it will work.

Cheers,
Jörg

[1] http://adobeaemclub.com/access-to-resourceresolver-in-osgi-services-aem-6-1/