Bundle Activation Error

Avatar

Avatar

umeshj24393

Avatar

umeshj24393

umeshj24393

28-04-2017

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

28-04-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. 

Answers (4)

Answers (4)

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

991

Correct Reply

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

991

Correct Reply

1.0K
Jörg_Hoh
Employee

30-04-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/

Avatar

Avatar

umeshj24393

Avatar

umeshj24393

umeshj24393

29-04-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...

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

991

Correct Reply

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

991

Correct Reply

1.0K
Jörg_Hoh
Employee

29-04-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

Avatar

Avatar

umeshj24393

Avatar

umeshj24393

umeshj24393

29-04-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..